Get Last date of every Month in a year

Hi All,
I need to find last date of month for given year.
Example:
I used to pass date or year such as 2012 or 01-01-2012(DD-MM-YYYY)
SQL query needs to return last date of every month such as
31-01-2012
28-02-2012
31-03-2012
30-04-2012
31-12-2012
for above requirement i have written the following SQL
select rownum as row_count,
case when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Jan_month,
case when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Feb_month,
case when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as mar_month,
case when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as apr_month,
case when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as may_month,
case when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jun_month,
case when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jul_month,
case when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as aug_month,
case when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as sep_month,
case when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as oct_month,
case when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as nov_month,
case when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as dec_month
from dual connect by level <= 12 order by rownum;
Result
Jan_Month
Feb_Month
Mar_Month
Apr_Month
may_month
jun_month
jul_month
aug_month
sep_month
oct_month
nov_month
dec_month
1
31-01-2014
2
28-02-2014
3
31-03-2014
4
30-04-2014
5
31-05-2014
6
30-06-2014
7
31-07-2014
8
31-08-2014
9
30-09-2014
10
31-10-2014
11
30-11-2014
12
31-12-2012
Excepted Result:
am excepted result as single row such as
Jan_Month
Feb_Month
Mar_Month
Apr_Month
may_month
jun_month
jul_month
aug_month
sep_month
oct_month
nov_month
dec_month
31-01-2012
28-02-2012
31-03-2012
30-04-2012
31-05-2012
30-06-2012
31-07-2012
31-08-2012
30-09-2012
31-10-2012
30-11-2012
31-12-2012
Kindly give me suggestion to archive above result.
Thanks&Regards
Sami

I agree with Marcus Pivot is the way to go about this... But on the other hand you almost solved it yourself.. just a max function was needed for your expected output:
select
max(case  when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Jan_month,
max(case  when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Feb_month,
max(case  when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as mar_month,
max(case  when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as apr_month,
max(case  when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as may_month,
max(case  when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jun_month,
max(case  when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jul_month,
max(case  when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as aug_month,
max(case  when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as sep_month,
max(case  when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as oct_month,
max(case  when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as nov_month,
max(case  when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as dec_month
from dual connect by level <= 12 order by rownum;
AND to avoid hardcoding you can also modify your query as :
select
max(case  when rownum=1 then last_day(to_date(to_char(rownum),'MM')) end) as Jan_month,
max(case  when rownum=2 then last_day(to_date(to_char(rownum),'MM')) end) as Feb_month,
max(case  when rownum=3 then last_day(to_date(to_char(rownum),'MM')) end) as mar_month,
max(case  when rownum=4 then last_day(to_date(to_char(rownum),'MM')) end) as apr_month,
max(case  when rownum=5 then last_day(to_date(to_char(rownum),'MM')) end) as may_month,
max(case  when rownum=6 then last_day(to_date(to_char(rownum),'MM')) end) as jun_month,
max(case  when rownum=7 then last_day(to_date(to_char(rownum),'MM')) end) as jul_month,
max(case  when rownum=8 then last_day(to_date(to_char(rownum),'MM')) end) as aug_month,
max(case  when rownum=9 then last_day(to_date(to_char(rownum),'MM')) end) as sep_month,
max(case  when rownum=10 then last_day(to_date(to_char(rownum),'MM')) end) as oct_month,
max(case  when rownum=11 then last_day(to_date(to_char(rownum),'MM')) end) as nov_month,
max(case  when rownum=12 then last_day(to_date(to_char(rownum),'MM')) end) as dec_month
from dual connect by level <= 12 order by rownum;
Easy way: (without connect)
SELECT LAST_DAY (TO_DATE (ROWNUM, 'MM')) AS Jan_month,
       LAST_DAY (TO_DATE (ROWNUM + 1, 'MM')) AS Feb_month,
       LAST_DAY (TO_DATE (ROWNUM + 2, 'MM')) AS Mar_month,
       LAST_DAY (TO_DATE (ROWNUM + 3, 'MM')) AS Apr_month,
       LAST_DAY (TO_DATE (ROWNUM + 4, 'MM')) AS May_month,
       LAST_DAY (TO_DATE (ROWNUM + 5, 'MM')) AS Jun_month,
       LAST_DAY (TO_DATE (ROWNUM + 6, 'MM')) AS Jul_month,
       LAST_DAY (TO_DATE (ROWNUM + 7, 'MM')) AS Aug_month,
       LAST_DAY (TO_DATE (ROWNUM + 8, 'MM')) AS Sep_month,
       LAST_DAY (TO_DATE (ROWNUM + 9, 'MM')) AS Oct_month,
       LAST_DAY (TO_DATE (ROWNUM + 10, 'MM')) AS Nov_month,
       LAST_DAY (TO_DATE (ROWNUM + 11, 'MM')) AS Dec_month
  FROM DUAL
Cheers,
Manik.

Similar Messages

  • Mdx query to get the last date of every month if the month is current month need current date..

    i have a scenario where i need the data of last date of every month and if the month is current month need current date data...
    is it possible using MDX...

    Hi Shashi,
    According to your description, you want to return the last day for each month except current month, right?
    In MDX, we can use ClosingPeriod function to return the member that is the last sibling among the descendants of a specified member at a specified level, here is a sample query for you reference.
    with member [measures].[a]
    as
    ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
    select {[measures].[a]} on 0,
    [Date].[Calendar].[Month].members on 1
    from
    [Adventure Works]
    And then use the IIF function to evaluate if the month is current month. Please refer to the links below.
    http://msdn.microsoft.com/en-us/library/ms145584.aspxhttp://msdn.microsoft.com/en-IN/library/ms145994.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to get min date of every month for six months?

    Hi, i have data like this.
    Process_date SEQ_No
    16-MAR-13     733
    09-MAR-13     732
    02-MAR-13     731
    24-FEB-13     730
    16-FEB-13     728
    09-FEB-13     727
    02-FEB-13     726
    26-JAN-13     725
    21-JAN-13     724
    12-JAN-13     723
    05-JAN-13     722
    29-DEC-12     721
    24-DEC-12     720
    15-DEC-12     719
    08-DEC-12     718
    03-DEC-12     717
    22-NOV-12     716
    17-NOV-12     715
    10-NOV-12     714
    03-NOV-12     713
    29-OCT-12     712
    23-OCT-12     711
    13-OCT-12     710
    05-OCT-12     709
    28-SEP-12     708
    22-SEP-12     707
    15-SEP-12     706
    08-SEP-12     705
    01-SEP-12     704
    everymonth admin will refresh actual data table and automatically this above table will update with unique seq_no and process_date.
    I need to extarct min date of everymonth(First refresh of last 6 months - excluding currrent month) and also seq_no related to that month so using joins(using seq_no - that is available in main table) i can combine actual data.
    I need result like:
    02-MAR-13     731 ( I don't need MAR as it should not take current month data)
    so i need final result like below:
    02-FEB-13     726
    05-JAN-13     722
    08-DEC-12     718
    03-NOV-12     713
    05-OCT-12     709
    01-SEP-12     704

    995263 wrote:
    Hi, i have data like this.
    Process_date SEQ_No
    16-MAR-13     733
    09-MAR-13     732
    02-MAR-13     731
    24-FEB-13     730
    16-FEB-13     728
    09-FEB-13     727
    02-FEB-13     726
    26-JAN-13     725
    21-JAN-13     724
    12-JAN-13     723
    05-JAN-13     722
    29-DEC-12     721
    24-DEC-12     720
    15-DEC-12     719
    08-DEC-12     718
    03-DEC-12     717
    22-NOV-12     716
    17-NOV-12     715
    10-NOV-12     714
    03-NOV-12     713
    29-OCT-12     712
    23-OCT-12     711
    13-OCT-12     710
    05-OCT-12     709
    28-SEP-12     708
    22-SEP-12     707
    15-SEP-12     706
    08-SEP-12     705
    01-SEP-12     704
    everymonth admin will refresh actual data table and automatically this above table will update with unique seq_no and process_date.
    I need to extarct min date of everymonth(First refresh of last 6 months - excluding currrent month) and also seq_no related to that month so using joins(using seq_no - that is available in main table) i can combine actual data.
    I need result like:
    02-MAR-13     731 ( I don't need MAR as it should not take current month data)
    so i need final result like below:
    02-FEB-13     726
    05-JAN-13     722
    *08-DEC-12     718 (why??? if we have 03-DEC-12     717)*
    03-NOV-12     713
    05-OCT-12     709
    01-SEP-12     704i think you want something like this:
    WITH T(d,s) AS
    select to_date('16-MAR-13','dd-MON-yy'),733 from dual union all
    select to_date('09-MAR-13','dd-MON-yy'),732 from dual union all
    select to_date('02-MAR-13','dd-MON-yy'),731 from dual union all
    select to_date('24-FEB-13','dd-MON-yy'),730 from dual union all
    select to_date('16-FEB-13','dd-MON-yy'),728 from dual union all
    select to_date('09-FEB-13','dd-MON-yy'),727 from dual union all
    select to_date('02-FEB-13','dd-MON-yy'),726 from dual union all
    select to_date('26-JAN-13','dd-MON-yy'),725 from dual union all
    select to_date('21-JAN-13','dd-MON-yy'),724 from dual union all
    select to_date('12-JAN-13','dd-MON-yy'),723 from dual union all
    select to_date('05-JAN-13','dd-MON-yy'),722 from dual union all
    select to_date('29-DEC-12','dd-MON-yy'),721 from dual union all
    select to_date('24-DEC-12','dd-MON-yy'),720 from dual union all
    select to_date('15-DEC-12','dd-MON-yy'),719 from dual union all
    select to_date('08-DEC-12','dd-MON-yy'),718 from dual union all
    select to_date('03-DEC-12','dd-MON-yy'),717 from dual union all
    select to_date('22-NOV-12','dd-MON-yy'),716 from dual union all
    select to_date('17-NOV-12','dd-MON-yy'),715 from dual union all
    select to_date('10-NOV-12','dd-MON-yy'),714 from dual union all
    select to_date('03-NOV-12','dd-MON-yy'),713 from dual union all
    select to_date('29-OCT-12','dd-MON-yy'),712 from dual union all
    select to_date('23-OCT-12','dd-MON-yy'),711 from dual union all
    select to_date('13-OCT-12','dd-MON-yy'),710 from dual union all
    select to_date('05-OCT-12','dd-MON-yy'),709 from dual union all
    select to_date('28-SEP-12','dd-MON-yy'),708 from dual union all
    select to_date('22-SEP-12','dd-MON-yy'),707 from dual union all
    select to_date('15-SEP-12','dd-MON-yy'),706 from dual union all
    select to_date('08-SEP-12','dd-MON-yy'),705 from dual union all
    select to_date('01-SEP-12','dd-MON-yy'),704 from dual
    SELECT MIN(D),
           MIN(S) KEEP(DENSE_RANK FIRST ORDER BY D)
      FROM (SELECT D,
                   S,
                   TO_CHAR(D, 'mm') M,
                   TO_CHAR(D, 'yy') Y,
                   DENSE_RANK() OVER(ORDER BY TO_CHAR(D, 'yy') || TO_CHAR(D, 'mm') DESC) RN
              FROM T)
    WHERE RN BETWEEN 2 AND 7
    GROUP BY M, Y
    ORDER BY 1 DESC

  • Last day of each month in a year based on a Input date?

    Hi all,
    I have a request from a customer who wants to have a yearly report created in BEx Query Designer which starts in January up to December and they want to have a Month To Date (MDT) and Year to Date (YTD) calculation of a key figure. This report will only show one year at the time based on the date the user give as input at the Variable Screen.
    This key figure should be calculated by using the last date of each month for input when performing the MTD and YTD calculation and summarizations.
    Example:
    January: 31.01.2008  Key Figure = 1000. MTD = 1000 and YTD = 1000
    February: 29.02.2008  Key Figure = 2500. MTD = (2500-1000) 1500 and YTD = 2500
    March: 31.03.2008  Key Figure = 6000. MTD =(6000-2500)=3500 and YTD = 6000
    Etcu2026.
    This means that I have to have a lot of hidden Key figures which gets restricted on the different month end dates and formulas to calculate the different MTD and YTD results for the months as the year progresses.
    The way I have solved it now is that I have a Customer Exit which gives me the Last day of last year (Exp: 31.12.2007) based on input date and use a Offset on the last day of last year date to get the different last dates of each month.
    Since we have a leap year (one extra day in February) this year, the offset to calculate the end month dates will be different for 2007 and next year (2009). This solution is not very flexible, and it will not give the correct MTD and YTD if the customer wants to go back to 2007 and off course next year (2009).
    One solution is to create 12 Customer Exits that gives me the different month end dates (January-December), and also takes in account leap year for February for the different years. These Exits will be based on the Input date the Customers put in at the variable screen.
    I would rather want to avoid making 12 new customer exits and want your advice and expertise to find out if this is possible in any other way (maybe with only 1 customer exit) to get the last date of each month based on an input date.
    Thanks for all your advices on beforehand.
    Regards
    Oddmar Lid

    Hi,
    Thanks for you replay and documentation, but it doesn't give me excatly the functionality I'm after. The only MTD calculation code the document provides is the calculation of the following functionality:
    "Month to Date (MTD) u2013 From the 1st of month to u201CKey Dateu201D - for current year." This doesn't give the the functionality I want, which is to retrieve a given vaule for a Key Figure for the last dates of the months in a year to calculate MTD and YTD.
    This way I have created the query is to have multiple hidden Key Figures that calculates the MTD and YTD.
    In Columns in Query Designer it will look something like this:
    Selection: MTD January--> Date = 31.01.2008, Key Figure (Always Show)
    Selection: YTD January --> Date= 31.01.2008, Key Figure (Always Show)
    Selection: MTD February --> Date= 29.02.2008, Key Figure (Always Hide)
    Formula: MTD February --> MTD February - MTD January (Always Show)
    Selection YTD February --> Date = 29.02.2008, Key Figure (Always Show)
    And so on....
    This is off course a simplified version, but it shows the core of the solution. What I want to achive here is that the dates used to get the Key Figures (last date of a month) is calculated as flexible as possible, so that the users can go back and forth in time without worrying about the leap year problem and so on. I have now used an offset from the last date of last year and this is good for all the normal years, but when it is a leap year the query will use wrong dates to get the key figure vaule for the last date of each month.
    Any ideas on how to achieve this without creating 12 different Customer Exit variables (one for each end date of each month)?
    Thanks
    Regards
    Oddmar Lid

  • Query for getting data for every quarter for financial year

    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.

    lakmesri wrote:
    Hi,
    My problem is I need to get the data for every quarter for financial year and also I need data for every week for financial year.
    For example for financial year 2012-13, Apr2012 to Jun2012 would be Q1, Jul2012 to Sep2012 would be Q2 and so on. Total 8quarters should come upto Apr2013.
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    How can you get 8 quarters within a year ? I'b be concerned here.
    lakmesri wrote:
    Hi,
    In the same way  1st apr 2012 to 7th apr 2012 would be week1, 8th apr to 15th apr would be week2 and son on. How to write a query for this scenario in oracle. Can anybody help me on this. very urgent..
    Thanks in advance.
    First, that question is really not clearly asked. Second how could it be urgent ? You even did not tell us your Oracle version, did not show any tables descr, output sample nor any effort on your side to work on.
    Nicolas.

  • Please help.........how can i get the last date of the month?????

    Hello....
    I want to get the last date of the month.
    For example, the last date of Jan is 31.
    How can I get the last date of the particular month and year ????
    Thanks for help.
    Gloria

    Hi Gloria
    1. How can I compare the date???date1.compareTo(date2)
    where date1 and date2 is a java.util.Date Object
    will return 0 if it is the same date
    or
    date1.after(date2)
    where date1 and date2 is a java.util.Date Object
    will return true if date1 is after date2
    (the same for date1.before)
    2. How can I change the date format into yyyymmdd format???? I just want the year, month and date.try the java.text.SimpleDateFormat Object
    new SimpleDateFormat("yyyymmdd").format(yourdate)
    Hope this help.
    Please also have a look at a calendar I wrote, (maybe it help)
    demo & source :
    http://www.geocities.com/globe_software/java/components/
    globe_sa

  • URGENT - BI Publisher - Get Last Date of Month/Year

    Hello,
    I want to get the last date of a year/month through BI Publisher. We want to do it by creating a list of values containing the month/year name (i.e. January, February, March for month or 2004 2005 2006 for year) and when the user selects one of this values to get the last date of the month or year in order to select the correct number of records.

    Hi,
    try with a LOV like the following:
    select
    to_char(add_months(trunc(sysdate,'MONTH'),-level),'Month - YYYY') display_value,
    last_day(add_months(trunc(sysdate,'MONTH'),-level)) return_value
    from dual
    connect by level <=12
    which gives you the last 12 month from today.
    Regards
    Rainer

  • How to get last date of month ?

    Dear all
    hi!!!
    How can I get the last date of a particular month?
    I mean if the month is Feb, last date of the month should be 28.
    Is it required to write in loop or there is any method to get it.
    Please write me urgently,
    thanx,
    Samir

    Hello ,
    You can get the last date of a particular month of a particular year like this :
    int year= 2000;
    int month=1;     // February (month is zero based )
    int date = 20;
    java.util.GregorianCalendar gc = new java.util.GregorianCalendar(year,month,date);
    int last_day = gc.getActualMaximum(Calendar.DAY_OF_MONTH));
    Sandip

  • Schedule a process chain on last saturday of every month

    Hi Guys,
    My requirement is to schedule process chain on last saturday of every month. Is there any way to do this?
    I am already aware of below document. So please do not reply with the same. But please let me know if I am missing on anything.
    I have a requSchedule a Process chain on specific weekdays
    Thanks,

    HI R P,
    As mentioned in 'Schedule a Process chain on specific weekdays' document to use decision step. You can go with it just before setting actual data flow PC steps. Here a help for  you.
    Logic for decision step-
    Create a new custom function/method (say ABC) to calculate last Saturday of every month by using Standard Method 'FIRST_DAY_IN PERIOD_GET' (this gives last Sunday of every month) and use code logic accordingly to get last Saturday.
    Now, pick this ABC function from 'User- Defined function' section for your decision step formula.
    Hope this help.
    Thanks!
    Pratish

  • Expression - First date and last date of current month, current year

    Hi
    I need to have 2 ssrs expression as I can use  as default parameters in my report where I can -  out from my Time dimension, get the
    first date of the current, current year - and one where I get last date, current month, current year.
    My data source is a SSAS cube and my timedimension is structured like this:
    [Time].[Days].&[2009-01-16T00:00:00]
    Any suggestions how to solve this ?

    Hi ,
    You can use below in Default Values in ssrs ;
    for first Day of current month and year
    ="[Time].[Days].&[" +Format(dateadd("m",0,dateserial(year(Today),month(Today),1)), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-01T00:00:00]
    For last day of current month and year
    ="[Time].[Days].&[" +Format(DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-30T00:00:00]
    Please correct me if I misunderstood your requirement.
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • Variable last date of previous month/last date of current month

    Hello Experts,
    I am facing an issue while designing a query.
    Requirement is like this.
    Report will be run on monthly basis.so on execution of report, it should prompt for month/year.
    now on report there are two columns for which I have to get data on date basis(last date of previous month and Last date of current month).
    Can anyone tell me is there any standard variable for this? what is it?
    or how to achieve this?
    Regards,
    Nirav

    Hi,
    See if this post in this forum can help you.
    Re: Last date of a month
    Regards
    Shalabh Jain

  • Getting last day of the month

    hi ,
    is there an existing date funtion to get last day of the month ?
    pls advise
    else
    i'll try to add_month + 1 to current month and format to the first day and minus 1 day from that new month
    tks & rdgs

    last_day function
    <br>
    jeneesh

  • First and Last date of any Month.

    Hi Friends,
    I have 2 fields in my table
    FROM DATE & TO DATE
    User can enter any date in these two fields, but at time of commit i want to change the FROM DATE to the first date of the Month user have entered. And for TO DATE i want to change the last date of the month.
    For Example :
    User Enters-
    FROM DATE 12-Mar-2003
    TO DATE 27-Jun-2003
    I want to change these date to:
    FROM DATE 01-Mar-2003
    TO DATE 30-Jun-2003
    How can I write a database function or procedure to control this thing.
    Please help.
    Best regards,
    Imran Baig

    It depends on your requirements, but I usually use TRUNC(date, 'D')
    to get the first day(Sunday) of the week, because TRUNC(date, 'W')
    returns the same day of the week as the first day of the month.
    See http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a85397/function.htm#80101
    for more info on this.

  • Terms of Payment to determine due date as last date of the month

    Hi Experts,
    Does any one know how to configure a Terms of Payment to determine due date as last date of the month ?
    I tried by puting fixed date as 31 in the Terms of Payment in FI but when I am creating in FI-CA it gives me an error "_Term of payment Z003 is inconsistent/not planned_"
    Please advice.
    Thanks & Regards
    Satyajeet

    Hi Satyajeet,
    It seems the settings that you have maintained in FI are correct.
    When you are assigning the payment terms in FI-CA, you need to assign a factory calendar as well to the payment terms in the following config-
    IMG->Financial Accounting ->Contract Accounts Receivable and Payable->Postings and Documents->Document->Maintain Payment Terms
    If you have already assigned the factory calendar and still the problem persists, can you give the message ID and the message number of the error that you are getting?
    Thanks,
    Amlan

  • Job to run last monday of every month

    Hello Experts,
    I have to create job which should run last Monday of every month. We have function module to find last Friday of every  month. I can add 3 days to get last Monday.
    We have to specify the job or event in the "Start Condition" of the job, how can we achieve this?
    Any help?
    Thanks,
    Venky

    Hi,
    Hi,
    Please use the below function module to raisa a event
    CALL FUNCTION 'BP_EVENT_RAISE'
      EXPORTING
        EVENTID                     = p_event
       EVENTPARM                    = ' '
       TARGET_INSTANCE              = ' '
    EXCEPTIONS
       BAD_EVENTID                  = 1
       EVENTID_DOES_NOT_EXIST       = 2
       EVENTID_MISSING              = 3
       RAISE_FAILED                 = 4
       OTHERS                       = 5.
    IF SY-SUBRC = 0.
    write: 'Event', p_event , 'was raised.'.
    else.
    write: 'Event', p_event , 'could not be raised. check transaction SM62 if event has been changed or non existent'.
    ENDIF.
    else.
      write: 'No change is detected'.
    endif.
    if the function module returns the last monday of the month.
    Then the job can be based on this event.
    -Vikram

Maybe you are looking for

  • DHCP problem with wireless clients

    I've just set up this eqipment Router/Firewall ASA 5505 Cisco WLC 2125 - Wlan controller Switch Catalyst 2960 16 Ap's  AIR-LAP1131AG-E-K9 Everything was working fine, but after a while there was a problem, spesially with cell phones with wlan and wit

  • Why can I not install Adobe Flash Player on my computer ?

    I am not able to install Adobe Flash Player on my computer. I have uninstalled a previous version. The new version says the installation was successful, but there is no installation.

  • IDoc runtime error

    Hi all, In my message mapping, I have mapped a source structure (0..unbounded) to an IDoc structure(0..unbounded) because I will be having a number of IDocs generated. The mapping works fine if the source structure has a non-zero occurence. However,

  • Oracle LOCATOR - Standard Edition

    Hello, Can you please to tell me if there is any customer using Oracle Locator with Standard Edition? Regards, Andre

  • Power Shell - Read from text file

    Looking to see how to output select data from c:\test\test.txt file to c:\test\output.txt based on the following condition. Select data from text file that has a category of "Salads" and only return the name of the Salad to a text file. test.txt cont