GET THE MONTH
HelloI need to generate months between two bays. Last span should be up to sysmonth. I appreciate your time.
With the help of 10g or 11g
EFFECTIVE_MONTH DIST_ID SHOP_ID SHOP_NAME
01/01/2008 P00112 PFR00809 TOKEN GLASSES
06/01/2009 P00112 PFR00536 MAVALI GLASSES
Required resultEFFECTIVE_MONTH DIST_ID SHOP_ID SHOP_NAME SHOP_MONTH
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jan-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Feb-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Mar-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Apr-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-May-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jun-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jul-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Aug-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Sep-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Oct-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Nov-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Dec-2008
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Jan-2009
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Feb-2009
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Mar-2009
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-Apr-2009
1-Jan-2008 P00112 PFR00809 TOKEN GLASSES 1-May-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jul-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Aug-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Sep-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Oct-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Nov-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Dec-2009
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jan-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Feb-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Mar-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Apr-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-May-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jul-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Aug-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Sep-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Oct-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Nov-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Dec-2010
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jan-2011
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Feb-2011
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Mar-2011
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Apr-2011
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-May-2011
1-Jun-2009 P00112 PFR00536 MAVALI GLASSES 1-Jun-2011
Hello
Here's one way:
WITH got_month_cnt AS
(
SELECT effective_month
, dist_id
, shop_id
, shop_name
, MONTHS_BETWEEN ( LEAD ( effective_month
, 1
, ADD_MONTHS ( TRUNC (SYSDATE, 'MONTH')
, 1
)
) OVER ( PARTITION BY dist_id
ORDER BY effective_month
)
, effective_month
) AS month_cnt
FROM table_x
)
SELECT c.effective_month
, c.dist_id, c.shop_id, c.shop_name
, ADD_MONTHS ( c.effective_month
, m.column_value - 1
) AS shop_month
FROM got_month_cnt c
CROSS JOIN TABLE ( CAST ( MULTISET ( SELECT LEVEL
FROM dual
CONNECT BY LEVEL <= c.month_cnt
) AS sys.odcinumberlist
) ) m
;
I'm just guessing at what role (if any) dist_id, shop_id and shop_name play in this issue.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
Published by: Frank Kulash, June 8, 2011 17:38
Tags: Database
Similar Questions
-
Is there one way other than to_char to get the month of the date field
Is there one way other than to_char to get the month of the date field
Hello
raj4tech wrote:
Is there one way other than to_char to get the month of the date field
EXTRACT is one:
SELECT INTERESTED (SYSDATE MONTHS) AS curr_month
DOUBLE;
-
get the month and year of date type
Hi all
I need to get the month and year of type date.
For example
Required result:select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
Any ideas?01-2011
Thanks in advance,
Bahchevanov.select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
HTH
-
How to get the month previous year?
Hello
I have to get the previous year three-months of the effective date, but I have a problem since the beginning of the year and it's because I set the incorrect query.
I mean:
I wrote this query
SELECT TO_CHAR(SYSDATE,'YYYYMM')-1, 2-TO_CHAR(SYSDATE,'YYYYMM'), TO_CHAR(SYSDATE,'YYYYMM')-3
FROM DUAL;
in order to get (on mars):
201502, 201501, 201412
but unfortunately, I get:
201502, 201501, 201500
Can you help me?
Thanks in advance!
Hello
Here's one way:
SELECT TO_CHAR (ADD_MONTHS (SYSDATE-1), "YYYYMM") AS the m1
, TO_CHAR (ADD_MONTHS (SYSDATE-2), "YYYYMM") AS m2
, TO_CHAR (ADD_MONTHS (SYSDATE,-3), "YYYYMM") M3
DOUBLE;
-
to get the month and year separated
Hello
I have the entry_date_fin of column (type of data-varchar2 (8))
with values like Apr.-2008
Feb-2009 etc.
can I get the distinct month and year separated
kindly guide mei tried select to_date(entry_date_fin,'MM') FROM xyz doesnt wrk
Although you are (wrongly, IMO) storage of dates as strings, just use string manipulation...
SQL> with t as (select 'FEB-2008' as txt from dual) 2 -- 3 select substr(txt,1,3) as mnth 4 ,substr(txt,5) as yr 5 from t 6 / MNT YR --- ---- FEB 2008 SQL>
-
How to get the maximum number of days in a month?
How to get the maximum number of days in a month?
I use a dateField. where I can get the month. Now, I want to get the maximum number of days in a month.
How can I get it?
Please help me. and thanks in advance... []
NET. RIM. Device.API.util
Class DateTimeUtilitiesgetNumberOfDaysInMonth (int month, int year)
Returns the number of days in the specified monthIt took me like 10 seconds to find it in the API, I guess you spent more time writing the post...
-
getting the value of the month
How to get the month value, my intention is that I have to get the month, julian months using it gives values from 1 to 12, but my intention is I want January as a text when 1 is filled and so on. Could you suggest on this.
Thank you
OlivierDominique, try this in the default value field: ToChar (Today (), "MMMM")
You can replace the today() with the field variable or the variable you need.
Good luck
Thom -
Retrieve the month following the date
Hi people,
How can I get the part of months to a date.
Say, like, I want to get the month part (April = 4) 01/04/2009.
Thanks in advance!Hello
You can get all parts of a DATE using TO_CHAR.
For example, on April 1, 2009SELECT TO_CHAR (SYSDATE, 'Month') FROM dual;
product of the results of this
April
(if you use English) and
SELECT TO_CHAR (SYSDATE, 'MM') FROM dual;
produces this output (VARCHAR2)
04
-
I bought an iphone6. I registered. On the apple's music. But I'm not able to get the free month trial subscription
What happens when you try?
-
I am trying to print a photo book, but get the message "a network error occurred during the processing of your order. Please check your network connection and try again. I had no problem with the printing of a book about a month ago.
Start in Safe Mode, Mac OS x: Safe Mode bootand try to order from there.
Don't forget to check out the book before ordering this Apple; Get an overview of a project on paper in Photos, iPhoto or Aperture to avoid problems - Apple Support. Save the PDF to be compared with the printed version when coming out.
-
I, like so many others, have problems with updates of Windows, as well as to download and install. My problems on my computer Windows 7 began in April 2016 during the "patch Tuesday". After having done everything I could think of, including communicate with Microsoft (which were absolutely no help!), I found a fix here - installation KB3145739. Since then, I was able to check the updates without problem - that is to say, until the most recent "patch Tuesday," which was this week may 10.
I had set my computer to "check for updates, but let me decide whether to download and install." Well, the computer doesn't seem to be looking up everything on Tuesday at all, so I checked manually for them, and as last month, the search seems to never end. After looking at some of the posts here, want to ask questions on exactly what to do. First, should I reinstall KB3145739? Also should I install or the other of the following - KB3153199 or KB3138612 - in addition to KB3145739 (fell on these two elsewhere on here as possible fixes)? Finally, should I change my settings to "never check updates" rather than as I have currently and always just manually check updates? Thanks for any help on this. I am so tired of MS causing problems with getting the updates (never had any problems until they start us pushing the 10).
(Just thought of another question - GWX control panel installation would be a good idea?)
Your most reliable way to identify the update is to check this page:
Other than that, start with Kernel Mode driver updates. ;)
Best regards, VZ
-
How to get the Date, month, year of the DateTimePicker
Hi, I am using the DateTimePicker.
There are several question about this command:
1. how to get the Date, month and year?
-With the help of myDateTime.value, I get this string ' Wed May 08 14:45 ICT 2013 '-> I have to manually analyze this? Because I need in format yyyy/mm/dd. Or can set the format of dateTimePicker.value?
2 format on dateTimePicker self (on the user interface) is d/m/YY, I can't change to another format?
Thank you
dateTimePicker.value return a QDateTime not a string.
https://developer.BlackBerry.com/Cascades/reference/bb__cascades__datetimepicker.html#property-value
See more:
https://developer.BlackBerry.com/Cascades/reference/QDateTime.html#date
https://developer.BlackBerry.com/Cascades/reference/QDate.html
You can get
day = dateTimePicker.value.date().day() month = dateTimePicker.value.date().month() year= dateTimePicker.value.date().year() dateYYYYMMDD = dateTimePicker.value.date().toString(Qt::ISODate) dateYYYYMMDD2 = dateTimePicker.value.date().toString("YYYY/MM/DD") dateYYYYMMDD3 = dateTimePicker.value.toString("YYYY/MM/DD")
-
As of Windows XP support ends in 2014, will I still be able to get anti virus updates and all the months of security beyond 2014 for Windows XP patches?
As of Windows XP support ends in 2014, will I still be able to get anti virus updates and all the months of security beyond 2014 for Windows XP patches?
From April 2014, no security/more operating system patches released at Microsoft (for the most part) for Windows XP. It's a BONE death in the eyes of its creator.
Your anti-virus software may or may not be supported - which depends on its own end of life such as decided by its supplier, and even if it is a Microsoft product, is not directly related to the lifecycle of Windows XP (you can say that as Windows XP came with no native antivirus/antimalware features.) -
How to get the last date of 3 days for the current month?
Hello. Guy
How to get the last date of 3 days for the current month?
MY OUTPUT WOULD LOOK LIKE THIS
JANUARY 29, 2016
JANUARY 30, 2016
JANUARY 31, 2016
GUYS HELP ME / / /...
SQL > select last_day (sysdate) - level + 1 double connect by level<= 3="" order="" by="">=>
LAST_DAY)
---------
29 JANUARY 16
30 JANUARY 16
31 JANUARY 16
-
How to get the last business day of the previous month?
Hi all
We need the user as below,
If the user select 18 June 2015 ' quick dashboard as the input value, and then they want to see last month last day of work (business date: 29-may-2015) amount in report, if you have an idea please share with us.thanks
Note:
use under request we can able to get the last day of the previous month, we want to for the last business day of the last month, based on the date of entry of the user?
TIMESTAMPADD (SQL_TSI_DAY,-(1), TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH ("DIM_TIME". ("" DataDate ") *-(1) + 1,"DIM_TIME ". (("" DataDate "))
Thank you
Deva
Try this,
case when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 1 then timestampadd (sql_tsi_day, (Dayofmonth(Date '2015-06-15') *-1)-2, Date '' 2015-06-15) when Dayofweek (timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15')) = 7 then timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1-1, Date '' 2015-06-15) another timestampadd (sql_tsi_day, Dayofmonth(Date '2015-06-15') *-1, Date ' 2015-06-15') end
As Ftsiot said in this post, it will work only to exclude the sat and Sun. Another one if you want to exclude regional holiday, you may need a calendar in DB table.
Thank you
AJ
Maybe you are looking for
-
iCloud inaccessible documents from Mac
I am running OS X.11.2 on a Mac mini (end of 2014) with 2.6 GHz Intel Core processor i5 and 8 GB 1600 MHz Ram and integrated graphics Intel Iris. I recently discovered that Pages 5.6.1 and Numbers 3.6.1 cannot open documents that are stored in iCloud
-
I'm almost certain that it is a virus problem because I could not afford to continue payments on my antivirus software. Someone please help. I really want to solve this problem quickly.
-
LaserJet 3052 jam in the output tray
Help! I have a paper jam in the output tray which cannot be extracted from the front. The manual says to remove the back panel, but there are no instructions to know how to get down panel rear and I'm afraid I'd break. It seems that there should b
-
Additional language in the language bar
I have a problem with the language of entry too, a little different: I installed (ENGLISH) and keyboard (french) EN "and setting/keyboard language and regional language", but the language bar automatically displays a third choice: VI (Vietnamese) and
-
Installation of LR6 on Mac OS El Capitan does not work
Hey,.I downloaded LR6 autonomous so that it supports the newest device, that I bought. I downloaded the installation files, and then down them. He asked to connect with the Adobe ID, which I did and then he asked for the license key that I entered, t