Need to know first day of current quarter

hi,
I want to implement a variable to dertermine the date range of "the quarter to date" of last year:
low: current date -364
high: first day of current quarter -364
so if anybody knows how to get the first day of current quarter, based on teh current date?
Thank you so much in advance,
Ping

Hi Ping,
Just curious whether the code worked or not and if it worked how did u solve the error message ?? keep us posted.
do the foll modifications to get last qtr.
data: qtr like sy-datum.
data: lqtr like sy-datum. --- newly added
if  sy-datum4(2) = '01' or sy-datum4(2) = '02' or
sy-datum+4(2) = '03'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0101'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0101'. --- newly added
elseif sy-datum4(2) = '04' or sy-datum4(2) = '05' or sy-datum+4(2) =
'06'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0401'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0401'. --- newly added
elseif sy-datum4(2) = '07' or sy-datum4(2) = '08' or sy-datum+4(2) =
'09'.
qtr(4) = sy-datum(4).
qtr+4(4) = '0701'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '0701'. --- newly added
elseif sy-datum4(2) = '10' or sy-datum4(2) = '11' or sy-datum+4(2) =
'12'.
qtr(4) = sy-datum(4).
qtr+4(4) = '1001'.
lqtr(4) = sy-datum(4) - 1. --- newly added
lqtr+4(4) = '1001'. --- newly added
endif.
write: qtr.
write: lqtr. --- newly added
Message was edited by: ravi raj

Similar Messages

  • Need sql querry for records between Current Year First day and Current Day

    Hi,
    I have a table like this...
    Empid     Empname     DOJ
    TEST1     ERDDF     19-Jun-2011
    TEST2     AA     22-Mar-2011
    TEST3     SS     22-Oct-2011
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    TEST8     ERDDF     28-Jun-2012
    My output like this...
    Empid     Empname     DOJ
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    Logic:
    records between Current Year First day and Current Day(sysdate)

    937506 wrote:
    Hi,
    I have a table like this...
    Empid     Empname     DOJ
    TEST1     ERDDF     19-Jun-2011
    TEST2     AA     22-Mar-2011
    TEST3     SS     22-Oct-2011
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    TEST8     ERDDF     28-Jun-2012
    My output like this...
    Empid     Empname     DOJ
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    Logic:
    records between Current Year First day and Current Day(sysdate)Probably you are looking for :
    where DOJ between trunc(sysdate,'YYYY') and sysdateRead {message:id=9360002} and always provide details mentioned in this thread.

  • Date for first day of current month

    How can i get the date for first day of current month ?

    select trunc(sysdate,'MM'),to_char(trunc(sysdate,'MM'),'DD'),to_char(trunc(sysdate,'MM'),'Day') from dual;

  • How to get the first day of current month

    hi guys,
    i am trying to get the first day of current month which get from the date i input at the selection screen. my method is not so good, so i was wondering if there is better way to get the this,
    thanks.

    Try this .
    data : DAYNR LIKE  HRVSCHED-DAYNR,
         DAYTXT LIKE  HRVSCHED-DAYTXT.
    data langu like sy-langu value 'EN'.
    Parameters PDATE LIKE SY-DATUM.
    PDATE+6(02) = '01'.
    CALL FUNCTION 'RH_GET_DATE_DAYNAME'
      EXPORTING
        LANGU                     = LANGU
        DATE                      = PDATE
      CALID                     =
    IMPORTING
       DAYNR                     = DAYNR
       DAYTXT                    = DAYTXT
      DAYFREE                   =
    EXCEPTIONS
      NO_LANGU                  = 1
      NO_DATE                   = 2
      NO_DAYTXT_FOR_LANGU       = 3
      INVALID_DATE              = 4
      OTHERS                    = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    WRITE :/ PDATE, DAYNR, DAYTXT.
    Cheers

  • First day of current month, one year ago

    All,
    Does anyone have a calculation or know how I can calculate the first day of the current month, one year ago? I am trying to setup a filter criteria to show all records created >= 1st day of current month for prior year and <= the last day of the prior month. I have the second half of the equation for last day prior month but need some help on the first half.
    Thanks in advance for any pointers!
    D

    You can try:
    SELECT TRUNC(ADD_MONTHS(sysdate, -12), 'MON') FROM dual;
    Or
    SELECT TRUNC(sysdate-NUMTOYMINTERVAL(1,'YEAR'), 'MON') FROM dual;

  • First Day of Current Month

    I need to return the first day of the current month. I have read I can use:
    WITH  MEMBER [Measures].[FirstDayOfMonth] AS 
    DateSerial(Year(Now()), Month(Now()), 1)
    However, this returns an incorrect format. Can this date member be formatted to yyyy-MM-dd?
    I have also read I can use OpeningPeriod but I could not get this to work.
    My date Hierarchy is:
    [Date].[Year Month Day].[Month]
    And my month members are in the yyy-MM-dd format, for example:
    [Date].[Year Month Day].[Month].&[2015-02-01]

    Thanks Richard,
    I am not sure what the "aa" string is for?
    Yes, I can get the current date using:
    WITH
    MEMBER [Measures].[Month Day] AS
    FORMAT(Now(), "yyyy-MM-dd")
    But I need to return the first date of the current month dynamically. For example, today this value would be: 
    [Date].[Year Month Day].[Month].&[2015-02-01]
    So I cannot use Parent or FirstChild as the hierarchy will not recognise the
    FORMAT(Now(), "yyyy-MM-dd") as a month member as it returns 2015-02-18.
    I believe I need to extract the current month day value, subtract this value from the Now() and add 1 (start of month), for example:
    StrToMember("[Date].[Year Month Day].[Month ].&[" + FORMAT(Now()-[Month Day]+1,
    "yyyy-MM-dd") +"]")
    Which will be 2015-02-18 - 18 + 1 = 2015-02-01
    Or:
    WITH
    MEMBER [Measures].[Month Day] AS
    FORMAT(Now()-[Month Day Value]+1, "yyyy-MM-dd")
    SET [FirstOfMonth] AS
    StrToMember("[Date].[Year Month Day].[Month].&[" + [Measures].[Month Day] +"]")
    So I need a new member to return the month day value.
    Does this make sense? Is there a better way to do this?

  • Last day of previous month, first day of current month

    Hi,
    Whats the best way to calculate the last date of the previous month, and the first day of the current month.
    Thank you for your help.
    Sumit.

    Here are FMs
    SG_PS_GET_LAST_DAY_OF_MONTH    FM calculating the last day of a month                                                                               
    FVOZ                                                                               
    RE_LAST_DAY_OF_MONTH                                                                               
    HRHCP00_TIME_HANDLING                                                                               
    HR_HCP_GET_LAST_DAY_OF_MONTH                                                                               
    HRVE_REPORTING                                                                               
    HRVE_LAST_DAY_OF_MONTH                                                                               
    RPDD                           HR-D: Payroll Germany                                              
    RP_LAST_DAY_OF_MONTHS          HR-D: Determine last day of month                                                                               
    SLS0                           PAW - Miscelaneous (MISC)                                          
    SLS_MISC_GET_LAST_DAY_OF_MONTH FM calculating the last day of a month                                                                               
    VVSRCH                                                                               
    LAST_DAY_OF_MONTHS                                                                               
    BWSO_DATE_GET_FIRST_WEEKDAY     
    CKSO                            
    CK_F_GET_FIRST_DAY_OF_DATE      
    HRBEN00SPENDA                   
    HR_BEN_SPENDA_FIRST_LAST_DAY    
    HRPB                            
    HRPP_CCODE_GET_FIRSTDAY_PERIOD  
    HRVE_PAYROLL                    
    HRVE_GET_FIRST_LAST_MONDAY      
    JBT6                            
    ISB_GET_FIRST_DAY               
    KED2                            
    RKE_GET_FIRST_DAY_IN_PERIOD     
    MCP2                            
    MC_PERIOTAB_BT_FIRST_LASTDAY    
    MC_PERIO_GET_FIRST_AND_LASTDAY  
    Thanks
    SK

  • Need to know the path of current Form/Report

    Hi All,
    I need to know the path of the Current Report/Form, but i dont want to use
    get_form_property(:system.current_form,file_name),
    is their any other way for getting the current path from where the report/form is running
    Imran Ahmed

    Hi,
    I dont want to use
    get_form_property(:system.current_form,file_name)
    because it give me the current directory with the form name for eg. (c:\dev6i\temp\abc.fmx) then i have to use
    cur_file_name := get_form_property(:system.current_form,file_name);
    total_length := length(cur_file_name);
    cur_form_name_length := length(get_form_property(:system.current_form,form_name))+4;
    path_length := total_length-cur_form_name_length;
    cur_path:= substr(cur_file_name,1,path_length);
    to get the actual path, and i dont find any function name GET_WORKING_DIRECTORY under WIN_API_ENVIRONMENT theie is get_windows_director and get_temp_directory but not the above, if you have that function then please mail me on [email protected] I also cannot use read_registry(forms_path) because in registry i have different paths.
    Thank You

  • Get date of first day of current week

    HI!
    Why does the following method do not return the date of the first day of the week in which the given date lies?
    public static int getFirstDayOfWeek(int year, int month, int date) { 
    GregorianCalendar GregCalendar = (GregorianCalendar)
    new GregorianCalendar(year, month, date).getInstance();
    while(GregCalendar.get(Calendar.DAY_OF_WEEK)!= Calendar.MONDAY) {
    GregCalendar.roll(Calendar.DATE, false);
    return GregCalendar.get(Calendar.DATE);     
    What I want the method to do:
    year = 2003
    month = Calendar.JANUARY
    date = 8
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY
    ==> GregCalendar.roll(Calendar.DATE, false);
    ==> GregCalendar.get(Calendar.DATE) == 7 (?????????)
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY
    ==> GregCalendar.roll(Calendar.DATE, false);
    ==> GregCalendar.get(Calendar.DATE) == 6
    ==> GregCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY
    ==> return GregCalendar.get(Calendar.DATE)
    But in reality, it always returns 6 grrrrrrrr
    What is wrong wirh it?
    Yours RB

    public Date getCurrentMonday()
            Date monday = null;
            Calendar rightNow = Calendar.getInstance();
            int day = rightNow.get(Calendar.DAY_OF_WEEK);
            int distance = 0;
            if (day == Calendar.MONDAY)
                monday = rightNow.getTime();
            else
                distance = day - Calendar.MONDAY;
                if (distance == -1)
                    distance = 6;
                monday = (Date) (rightNow.getTime());
                monday.setTime(monday.getTime() - 1000 * 60 * 60 * 24 * (distance));
            return monday;
        }

  • Current date, first day of month, last day of month, current week, current

    Hi All,
    may be the question will sounds basic for your guys, I am connecting via MDX a cognos reportnet on a BW 3.0B..due to loads of limitations on filtering via MDX on 'business date/time functions' , I would need to create in the infoqueries that are my data sources, the following additionnal objects:
    - current date
    - first day of current month
    - last day of current month
    - current week
    - current year
    I do not want prefiltered infoqueiries but object with these single values so that from reportnet I can have something like: OCALDAY between 'first day of current month' and 'last day of curent month'
    Is there standard fonction for this under BW/BEX or if we need to developp functions has nayone some code examples.
    thanks a lot for your great input
    David

    Hi,
    In universe level if you want implement the requirede functions then you have to write custom sql and if you want to implement them in Reporting level then most of the functions are available to you. e.g. Quarter,Month, Year, Current Date....
    Cheers,
    Suresh A.

  • Need the first day of the year and last day of the year.

    hi all,
    i need a function module which can get me the first day of current year and last day of the current year??
    please help.

    Similar date questions are being asked ALL THE TIME.  Please search.

  • Want to make Monday as the first day of the week in GregorianCalendar. how?

    hi
    I need to know what day is the first of the month is. for example the 1st of Nov 2004 is Moday and 1st of Dec 2004 is saturday.
    I am using the GregorianCalendar:
    1.  GregorianCalendar calendar = new GregorianCalendar(2004,11,1);    //set date to 1st Nov 2004
    2.  int firstDay = calendar.get(Calendar.DAY_OF_WEEK);now firstDay is 2. This is because the week starts from Sunday, so Monday is the 2nd day.
    But I am in Uk and my Uk Calendar shows monday as the first day (even in Windows 2000 Calendar).
    I would like the GregorianCalendar to have Monday as the first day of the week, so that the
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    returns 1 in the above case.
    I also tried adding
    calendar.setFirstDayOfWeek(Calendar.MONDAY); just between line 1 and line 2, but it did not help.
    This is because i don't want to manually subtract 1. If i manually subtract one, then the program might not work in other locale and timezones.
    Also if I subtract 1, then for 1 Feb 2004,
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    will return 1 as 1st Feb 2004 falls on Sunday. so if i subtract 1 it will be 0, so I have to do a extra checking for 0.
    Is there anyway to make the Calendar have Monday as the first day of the week??
    Tanveer

    hi
    I need to know what day is the first of the month is.Why does this matter? Since we know that 1 == Sunday and 2 == Monday... Why do you need Monday to be == 1? and couldn't you just subtract 1 if it's so important?
    for example the 1st of Nov 2004 is Moday and 1st of
    Dec 2004 is saturday.
    I am using the GregorianCalendar:
    1.  GregorianCalendar calendar = new
    GregorianCalendar(2004,11,1);    //set date to 1st Nov
    2004
    2.  int firstDay = calendar.get(Calendar.DAY_OF_WEEK);now firstDay is 2. This is because the week starts
    from Sunday, so Monday is the 2nd day.
    But I am in Uk and my Uk Calendar shows monday as the
    first day (even in Windows 2000 Calendar).
    I would like the GregorianCalendar to have Monday as
    the first day of the week, so that the
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    returns 1 in the above case.
    I also tried adding
    calendar.setFirstDayOfWeek(Calendar.MONDAY);[/cod
    ] just between line 1 and line 2, but it did not help.
    This is because i don't want to manually subtract 1.
    If i manually subtract one, then the program might not
    work in other locale and timezones.
    Also if I subtract 1, then for 1 Feb 2004,
    int firstDay = calendar.get(Calendar.DAY_OF_WEEK);
    will return 1 as 1st Feb 2004 falls on Sunday. so if i
    subtract 1 it will be 0, so I have to do a extra
    checking for 0.
    Is there anyway to make the Calendar have Monday as
    the first day of the week??
    Tanveer

  • FM for First day of the Fiscal Year.

    Hi ,
          i want to calculate First day of the Fiscal Year ,please send me the FM name urgently.
    Thanks  in advance

    hi,
    BAPI_CCODE_GET_LASTDAY_FYEAR
    this will give you back the last day of a fiscal year for a company code, but if you start with previous year, than you add 1 to the result, than you get first day of current fiscal year.
    FIRST_AND_LAST_DAY_IN_YEAR_GET
    this will give you back the first and the last dates of a given year, but you'll need the period version as well.
    hope this helps
    ec

  • Date Functions( first day of a month that is 3 months from now....)

    I have recently written my first stored procedure.
    Its rather a bunch of SQL statements.
    I had to hard code lot of dates. most of them are first day of the current monthe or last day of current month etc.
    I thot of parametrizing all the dates, but if a business person has to include all the parameters they could go wrong and get the wrong results.
    Now, I want to use date functions to achieve these requirements:
    Can any one please throw some insght into this:....
    1) First day of current month,
    2) last day of current month.
    3) first day of previious month
    4) last day of previous month
    5) first day of a month that is 3 months from now.
    6) last day of a month that is 3 months from now.
    7).....
    Can any one please throw some light on any one of this.. I can try to work from there onwards ....
    Thanks a lot in advance,
    Ac

    Hi there,
    1) First day of current month
    select trunc(sysdate, 'MM') from dual;
    2) last day of current month.
    select trunc(add_months(sysdate, 1), 'MM') - 1 from dual;
    3) first day of previious month
    select trunc(add_months(sysdate, -1), 'MM') from dual;
    4) last day of previous month
    select trunc(sysdate, 'MM') - 1 from dual;
    5) first day of a month that is 3 months from now.
    select trunc(add_months(sysdate, 3), 'MM') from dual;
    6) last day of a month that is 3 months from now.
    select trunc(add_months(sysdate, 4), 'MM') - 1 from dual;cheers,
    Anthony

  • For the previous month first day and last day

    i want to schedule my reports from the last month first date to last month last date.
    any body have queries for the while scheduling to uuse it.
    Ex:sysdate() - today's date
    first_day_of_month()- first day of current month
    first day of last month ---?
    last day of the last month ---?

    In the parameter, put this
    {$FIRST_DAY_OF_MONTH()$}other values you can use in default parameter values are
    {$SYSDATE()$} - to get current date
    {$FIRST_DAY_OF_MONTH()$} - to get first day of the current month
    {$FIRST_DAY_OF_YEAR()$} - to get first day of the current year
    {$LAST_DAY_OF_MONTH()$} - to get last day of the current month
    {$LAST_DAY_OF_YEAR()$} - to get last day of the current year
    Re: Default date as first of month
    TO get last day of last month
    {$FIRST_DAY_OF_MONTH()-1$}You can add/subtract number with these functions and no other functions are available.

Maybe you are looking for

  • Never ever ever ever change my appointment times in iCal!

    I have read dozens of posts.  I have played with the settings and my behaviour until I am sick. In >30 years of using both paper and electronic diaries, I HAVE NEVER ONCE SET A TIME FOR ANY OTHER TIME ZONE APART FROM THE RELEVANT ONE FOR MY MEETING!!

  • Title of a Crystal Report PDF being displayed in a web browser

    I have an application that previews a report in a web browser by saving the report to the web server and then opening a new tab/window pointing at the pdf that was just created. Right now it is displaying the server name(and path to the report on the

  • Duplicating a CTR Global Virtual Channel in MAX does not update the CO.Pulse.Term setting

    Hi,  Here is the issue description: MAX version: 4.6.2f1 daqmx:  9.0.2 Hardware: cDAQ-9178 , NI-9474 Digital output. For this module one has: crt 0 out  <--> PFI3  ctr 1 out  <--> PFI7 crt 2 out  <--> PFI1 ctr 3 out  <--> PFI5 1. In MAX create a Glob

  • AEBS, speeds suddenly slow on my Mac only

    The past few days, my internet at the house has been quite slow, where everything has previously gone fine. I've tried a restart, to no avail, and ran a quick test with my iPhone on the same network, using iNetworkTest.com. iPhone speed - 718kbs Mac

  • Mail Activity Wheel for each Mailbox no longer in M.Lion

    Until Mountain Lion, when Mail (version 6) accessed my mailboxes, each mailbox displayed a grey Activity Wheel. This is not happening in M.Lion. Under the button "Mail Activity" there is a progress bar when an attachment is being downloaded, and a me