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?

Similar Messages

  • 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;

  • 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

  • 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

  • First day of previous month

    Hi,
    I created a data parameter and I want my date parameter default value to be the first day of previous month, the expression {$FIRST_DAY_OF_MONTH()$} is pointing to the fitst day of current month and when I tried {$FIRST_DAY_OF_MONTH()-1$} it is just subtracting a day(thought to go back one month)...Is there way I can point my default value to first day of previous month.?
    Regards

    hmm is BI Publisher in Beta? Are there any workarounds you can suggest me to achieve this?
    I see the user stated that a workaround is possible at RTF template level? How can we achieve this?
    Re: Default date as first of month
    Edited by: user8937215 on Aug 10, 2010 7:30 AM

  • I want the minimum of the horizontal axis to be the first day of the month.

    I have a situation where I want the minimum of the horizontal
    axis(with date time axis) to be the first day of the month. I
    attempt it like so:
    var max:Date = new Date();//current date is our max from
    which we will calculate the min
    var min:Date = new Date(max.fullYear,max.month,1);
    dateTimeAxis.minimum = min;
    However this first date on this axis is the last day of the
    previous month for example 31 August instead of 1 September. Any
    ideas how to fix?

    Nikos, the only thing I can think of (off hand) is that it's
    defaulting to "zero" hour on that date, if you tried:
    var min:Date = new Date(max.fullYear,max.month,1,13);
    Would that make it work? That would set the date to 1pm.
    Have you considered defining the axis with the data you are
    binding to?
    Cheers,
    David

  • Report for current day and current month

    Hi gurus,
    i 've a report, where i 've to display the values for qty and cost of the material for the current day and current month
    HOw can i do this in BEx Query designer..If any document plz share
    thanks
    rakesh

    hi Kolli
    here i want to filter the data on system date,
    i wnt the report to pick the date dynamically based on the system date.
    but i think restricting on calmonth and calday is not going to solve my scenario..
    rakesh

  • Current day and no of days in current month

    Hi all,
    can anbody tell me which object is used for current day and no of days in current month.

    Hi,
    USe /OSP/GET_DAYS_IN_MONTH Function Module, just give Date you will get No. Of days in that Month.
    Use SY-DATUM for current date.
    Ex:
    Data: dt type SY-DATUM.
    dt = SY-DATUM.
    so you get current date in dt.
    Thanks
    Reddy

  • ABAP for the first day of the month

    Hello BW users,
    I have a scenario which uses an ODS with cumulative key figures with Addition update type. An infocube gets data from ODS by start routine in cube's update rule. I update this ODS first then infocube. All the loads are Full and are loaded daily. This is a snapshot scenario and I load the ods on itself then load from another infocube let's say Cube1. After successful load, I update infocube on itself again then update from the same infocube, Cube1, as in ODS. Infocube load sequence is same as ODS. In the scenario ODS and infocube are wanted to be updated daily. Therefore, I have to delete the ODS's (since it is addition update type) and infocube's overlapping data in the process chain that automates the load. At this point I need two things:
    1- ABAP program that is going to give me the first day of each month.
    2- ABAP program that is going to delete the overlapping data in ODS when I load it daily. Since I can do that for infocube in process chain with standard process type of Delete overlapping requests from infocube I need it only for ODS. Because there is no standard process type to delete overlapping requests in ODS (since its update type is Addition).
    I appreciate your help. Thank you in advance.
    Sincerely,

    1- ABAP program that is going to give me the first day of each month.
    if sy-datun+6(2) = 01.
    SY-FDAYW should give you the day
    endif.
    2- ABAP program that is going to delete the overlapping data in ODS
    REPORT  <PGM NAME>.
    TABLES: RSODSACTREQ , rsseldone.
    Parameters : odsname type RSINFOCUBE default '<>ODS NAME'.
    DATA: temp_REQUEST LIKE RSODSACTREQ-REQUEST,
          temp_REQUEST1 LIKE RSODSACTREQ-REQUEST,
          temp_RNR LIKE rsseldone-RNR.
    DATA: BEGIN OF itab OCCURS 0,
          REQUEST LIKE RSODSACTREQ-REQUEST,
          TIMESTAMP LIKE RSODSACTREQ-TIMESTAMP,
          END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
          RNR LIKE rsseldone-RNR,
          seldate LIKE rsseldone-seldate,
          seltime LIKE rsseldone-seltime,
          END OF itab1.
    SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
      WHERE ODSOBJECT = '<ODS NAME>'.
    SORT itab DESCENDING BY TIMESTAMP .
    READ TABLE itab INDEX 1.
    temp_REQUEST = itab-REQUEST.
    SELECT RNR seldate seltime FROM rsseldone INTO TABLE itab1
      WHERE source = '<Info Source Name for the ODS>'.
      SORT itab1 DESCENDING BY seldate seltime .
      READ TABLE itab1 INDEX 1.
      temp_RNR = itab1-RNR.
    *If   temp_REQUEST = temp_RNR .
    CALL FUNCTION 'RSSM_PROCESS_REQUDEL_ODSO'
      EXPORTING
        I_ODS             = odsname
        I_REQUEST         = temp_REQUEST
        I_JOBNAME         = 'i_jobname'
        I_VARIANT         =
        I_INSTANCE        =
      IMPORTING
        E_ERROR           =
        E_T_MSG           = itab1
      E_T_RNRLIST       =    ITAB1.
    *else.
    *raise exception.
    *endif.
    clear itab.
    refresh itab.
    SELECT REQUEST TIMESTAMP FROM RSODSACTREQ INTO TABLE itab
      WHERE ODSOBJECT = '<ODS NAME>'.
    SORT itab DESCENDING BY TIMESTAMP.
    READ TABLE itab INDEX 1.
    temp_REQUEST1 = itab-REQUEST.
    if temp_REQUEST = temp_REQUEST1.
    raise exception .
    endif.

  • Show data of last day of previous month against any day of current month

    Hi,
    I have fact table which contains data at date level (we have data for oct-2009 to april-2010). Our requirement is to show data of last day of previous month against any day of current month in obiee 11g. I am facing problem in Feb 2010 its picking data of 28-Jan-2010 instead of 31-jan-2010 and for April its picking data of 30-mar-2010 instead of 31-mar -2010.
    Any suggestion ???

    You're asking to filter your data set to only include rows between:
    1) last day of the previous month
    2) any day of the current month
    This can be achieved with prompting in OBIEE Answers.
    last day of previous month = TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) . The problem is you need to make query work within Oracle's Answer syntax.
    In the prompt, select the operator type for your date dimension as 'between' and default to 'SQL Results'.
    For the 'last day of previous month' , use the query:
    SELECT
    case when 1=0 then Time."Fiscal Date" else TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
    end
    FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
    For the current date, use the query:
    SELECT
    case when 1=0 then Time."Fiscal Date" else CURRENT_DATE
    end
    FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
    Another option is to create a last_date_pervious_month variable in the RPD and have that as the default value in your prompt.

  • How to get the first day in the month from a domain date ?

    Hi,
    I like to know how to get the first day in the month from a domain date?
    Thanks
    Stephen

    Hi Gokul...
    Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
    Its similar to the above one but instead of writing case statement you can achive the following.
    data : w_res type i,
             w_data type d,
    w_res = w_date mod 7.
    w_date = w_date - w_res.
    write w_date.
    This works.
    Regards,
    Siddarth

  • Function module to get the 'first day of next month'

    Hi
    I have a selection screen with  input fields
    1. period (month eg: 07)
    2.year(fiscal year eg: 2008 )
    If user enters 07 as month and 2008 as year, then I have to display 08/01/2008(MM/DD/YYYY) as output.
    Requirement is to calculate the  'first day of next month'
    I have written code for this requirement.But I am asked to use function mdule.
    Please help me in this regard.
    Thanks&Regards
    Rama.Mekala

    hi try this FM ...
    HR_JP_MONTH_BEGIN_END_DATE
    it gives the Begin Date and End date of the month
    rewards points if found useful
    regards,
    Balaji

  • 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

Maybe you are looking for