How to get year,month,date from a Date object?

thanks

The getTime() method will return the number of milliseconds since January 1, 1970, 00:00:00 GMT. You can then write a number of functions to calculate the date from this.
The toString() function returns a string with the current value of the object - i.e 2002-10-17 (it's unusual formatting (YYYY-MM-DD) is useful when validating an input in real time, though beyond this, I've no idea why they put it this way around). You can then use string function substirng() to break this down into parts.
i.e. if your Date object was called today:
String DD = today.toString().substring()(8)
String MM = today.toString().substring()(5,2)
String YYYY = today.toString().substring()(0,4)
There are other methods (see API) - but these have been deprecated - that means, although they can be used, they are not recomended.
There is also a Calendar object, though this seems to have the same problems.
Hope this helps :)

Similar Messages

  • How should get last month value from report?

    Hi experts,
    How should last month value. For example
    jan    feb    march
    100   --       ---
    Here i want to get jan month value in march coloumn.

    Hi ,
    It is only show last month value. but my requirement is if last month is empty it should bring Before Last month.
    For Example
      Jan       Feb       Mar
    1000   
    i need if the Feb value is empty should come jan month value.

  • How to get previous month data from current month values

    Hi Experts,
    I have made one universe from BW Query in which Fiscal year period is entered in interval.
    I have made a universe from that and want to develop webI reports on top of that.
    In my webI reports, i have used one cross tab. In Rows section i have added Company Code and in Column section i have used Fiscal Year/Period and in Value section i have added Sales Value. I want this value of previous month.
    Requirement:
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Jan'09         Sales of Feb'0f         and so on....
    I am getting this.
    Ex.
                            Feb'09          Mar'09     and so on...
    Comp_code1   Sales of Feb'09         Sales of Mar'09         and so on....
    I hope i have clear my requirements.
    Please help as soon as possible.
    Thanks in Advance,
    Rishit

    Hi Rishit,
    Follow the below steps to get the desired result.
    Step1: Convert your fiscal year period from char to a date in your database or in your designer however its feasible.
    to_date('substr('009.2009',2)','mm.yyyy')
    you will get the result 01 sep 2009
    Step2: Convert this format to 01/09/2009 by using date functions.
    Step3: Create a Detail associated to the 'date' field (typically your fiscal period).
    Step4: Create a cross tab Like : Rows section should have Company Code and in Column section should have 'date'(created detail) and in Value section should be Sales Value.
    you should get the following result.
    01/02/2009 01/03/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Step5: Use the following formula in your Column (date) formula bar.
    =(<date>-1)-DayNumberOfMonth(<date>-1)+1
    You will get the following result:
    01/01/2009 01/02/2009 and so on...
    Comp_code1 Sales of Feb'09 Sales of Mar'09 and so on....
    Format the cell according to your reruirement.
    Let me know if you will get any break in the above steps.
    Regards,
    Swati.

  • How to get next months date

    Hi. How do i return date records of next month?
    I am aware i may need sysdate.
    At the moment i have been trying:
    WHERE delivery_date = ADDMONTHS (sysdate, 1);
    No avail.
    Ideas?

    Hello
    If you mean you want to set up a range from the start of next month to the end of next month. This shows what happens when you apply add_months to sysdate
    SQL> select sysdate from dual;
    20-NOV-05
    SQL> select add_months(sysdate,1) from dual;
    20-DEC-05
    --Truncate sysdate to the first day of the month and then add 1 month
    SQL> select add_months(trunc(sysdate,'MM'),1) from dual;
    01-DEC-05
    --do the same, but use LAST_DAY to get the date of the last day next month
    SQL> select add_months(trunc(sysdate,'MM'),1),last_day(add_months(trunc(sysdate,'MM'),1)) from dual;
    01-DEC-05 31-DEC-05So with that in mind, you probably need to do something like
    WHERE
        delivery_date BETWEEN add_months(trunc(sysdate,'MM'),1) AND last_day(add_months(trunc(sysdate,'MM'),1));If you just want to get rows for "this" day next month you may well need to set a date range up especially if the delivery_date has not been truncated to set the time portion to 00:00:00
    WHERE
        delivery_date = ADD_MONTHS(TRUNC(sysdate),1))
    WHERE
        delivery_date >= ADD_MONTHS(TRUNC(sysdate),1))
    AND
        delivery_date < ADD_MONTHS(TRUNC(sysdate),1)) + 1HTH
    David
    Message was edited by:
    david_tyler

  • How to get whole month date based on date

    hi
    i have data at cube with calday and calyear/month
    when ever i entre date like 17/03/2009 , i want output not from 17th , i need output whole month of march?
    please let me know

    Hi,
    Here is the solution:
    1. Create 'ZM_END' Customer exit variable on 0Calday.
      Properties: Mandatory
                  Intervel
                  Uncheck ready for Input
                  0calenderday   
    2. Create ZCDAY User entry Variable on 0Calday
      Properties: Mandatory
                      Single 
                      Check ready for Input
                      0calenderday   
    3. In columns create new selection and then drag & drop your Keyfigure and also Drag 0CALDAY and then restrict 0CALDAY with Variable - ZM_END
    If user will enter 17/03/2009, then the result is from 01/03/2009 to 31/03/2009. I think this is what you are expecting.
    DATA: ZT_SDT TYPE SY-DATUM,
                       SDT TYPE SY-DATUM,
                       ZT_DT1 TYPE SY-DATUM,
                       ZT_DY(2) TYPE N,
                       ZT_MT(2) TYPE N,
                       ZT_YR(4) TYPE N,
    WHEN 'ZM_END'.
      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
        IF sy-subrc = 0.
          CLEAR: l_s_range.
          ZT_SDT = loc_var_range-low.
          ZT_DY = '01'.
          ZT_MT = ZT_SDT+4(2).
          ZT_YR = ZT_SDT+0(4).
          CONCATENATE ZT_YR ZT_MT ZT_DY INTO ZT_DT1.
          CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
            EXPORTING
              DAY_IN                  = ZT_SDT
           IMPORTING
             LAST_DAY_OF_MONTH       = SDT
           EXCEPTIONS
             DAY_IN_NOT_VALID        = 1
             OTHERS                  = 2
          IF SY-SUBRC <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          l_s_range-low = ZT_DT1.
          l_s_range-high = SDT.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
      ENDLOOP.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Mar 18, 2009 3:33 AM

  • How to get Year to Date data

    Hi all,
    I have the following scenario:
    Count -- Code -- Date
    5 -- DS -- 09/01/2009
    5 -- DS --- 15/01/2009
    5 -- LO -- 21/01/2009
    1 -- IL -- 09/02/2009
    5 -- DS -- 09/03/2009
    5 -- LO -- 09/04/2009
    4 -- DS -- 09/05/2009
    5 -- IS -- 09/06/2009
    5 -- DS -- 09/07/2009
    5 -- IS -- 09/08/2009
    3 -- DS -- 09/09/2009
    5 -- DS -- 09/10/2009
    5 -- LO -- 09/11/2009
    2 -- DS -- 09/12/2009
    5 -- DS -- 09/01/2010
    5 -- LO -- 09/02/2010
    4 -- DS -- 09/03/2010
    How can I only bring YTD data for 2009 and YTD data for 2010.. means YTD 2009 data till current day of the date e.g., if its 9 March today .. tbe result will bring full jan, feb and till 9th day of march '09 and full jan, feb and till 9th day of march '10
    Thanks
    Edited by: [email protected] on Mar 9, 2010 11:03 PM
    Edited by: [email protected] on Mar 9, 2010 11:06 PM

    Hi !
    Basic idea is
    select to_date('01012009','DDMMYYYY')+level-1
      from dual
    connect by level <= to_date('02022009','DDMMYYYY')-to_date('01012009','DDMMYYYY')+1with some "gymnastics" ( union all , case .... ) you will query which will be good for your requirements
    T

  • For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?

    For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?

    contact itunes support

  • How to get payment document number from paid column in monthly invoice

    Dear experts
    I use SBO japan version and i need to know how to get payment document number from paid column in monthly invoice ?
    in table MIN1, only contain invoice and credit note document number, there is no payment document number
    thank you for your help
    Best Regards
    JeiMing

    Dear Gordon
    Yeah, you are right, i can use field MIentry in RCT2
    thank you
    Best regards
    jeiming

  • How to get sales order data in substitution of fi-docu from GM posting ?

    How to get sales order data in substitution of FI documents from goods movement posting?
    When I posting a material document with movement type "501E", the system will creating a FI document automatically. And I need to get the sales order data in the substitution of FI document.
    I tried to export the data of the material document in user-exit "MB_CF001 Updating of material document data upon posting", but this user-exit does not triggered in the posting process at all. what's the problem?
    Do you have better solution or idea for this? Please help me. Thank you!

    Hello Harish,
    Please use BAPI_BUSPROCESSND_GETDETAILMUL to read details of sales order. This works as a remote enabled counterpart of CRM_ORDER_READ.
    Similarly if you want to display sales order from R/3, use FM BAPI_BUSPROCESSND_DISPLAY.
    Regards
    Kaushal

  • About year(), month(), date(), hour(), minute(), second() in Oracle

    In DB2, I can get the value of year, month, date, hour, minute, second from current timestamp by year(), month(), date(), hour(), minute(), second(). Like below SQL,
    SELECT current timestamp, year(current timestamp), month(current timestamp), date(current timestamp), hour(current timestamp), minute(current timestamp), second(current timestamp) FROM DUAL
    In Oracle, how can I modify above SQL?
    That is, do we have the corresponding function to each one of them in DB2?
    Thanks,
    JJ

    Hi Turloch,
    Thanks for your help.
    Here, I have another question.
    How about the days caculation?
    For example, in DB2, I have a SQL as below,
    select
    account_no
    from
    lit_transaction
    where
    ( start_date + no_of_days days - exp_days days) <= CURRENT DATE
    How can I modify above days caculation for Oracle?
    Thanks,
    J.

  • How to fetch year till date value for earning for current ,last and year

    hi,
    how to fetch year till date value for earning for current ,last and year before that from payroll result
    plz reply soon,
    pratyush

    Dear Pratyush,
    Pick this from CRT.
    Use LDB PNPCE & Fire event GET PAYROLL &
    then you can pick from CRT.
    Hope this helps.
    Kindly reward in case useful.
    Regards & Thanks,
    Darshan Mulmule

  • How to get the current date ? in the form of dd/mm/yyyy?

    Hi all,
    As getDate( ), getMonth( ), and getYear( ) is depricated, how to get the current date or System date, month and year ? please help ??
    Regards
    Ashvini

    HI,
    Than u for the reply. But i am getting one error.
    as u said, I tried to do so.........
    but, i am getting one error.
    code
    Calendar cald=(Calendar.getInstance.getTime());
    out.println(cald);
    error message
    validate$jsp.java:86: Attempt to reference method getInstance in class java.util.Calendar as an instance variable.
    Calendar cald=(Calendar.getInstance.getTime());
    ^
    1 error
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
    Pls help
    Regards,
    Ashvini

  • How to get the monthly interest rate

    Hello!
    I have been using AppleWorks for 10 years.
    Since that time, I use a financial template named Mortgage Analyser.
    In this file, one can get the pmt if one provided the +pv, monthly interest rate and the number of periods.+
    What I get is the reverse, that is, how to get the +monthly interest rate+, if I provide the +pv, the number of periods and the pmt+?
    I think I had this in the past, but I can not find it.
    Thanks,
    Jorge Lucas (the guy from Rio Grande do Sul)

    Peter,
    I already saw that, but it does not give me what I want.
    That works only if you put a money at a savings account and DO NOT TOUCH IT for a given period.
    My need right now is to help a girl to buy a car in 36 or 48 monthly payments and calculate the real interest.
    I want to have this for any other similar buying.
    I can do it using the Mortgage Analyser template changing the MONTHLY RATE by *+try and error+* but — +since I am a High School Math Teacher+ — I would like to have the function directly.
    Another day I was looking on the Internet and it seems that there is no direct response for what I want, using AppleWorks.
    So, if I continue to use AW, I must calculate it by try and error.
    Thanks anyway!
    Jorge Lucas (the guy from Rio Grande do Sul)

  • Need formula in my subreport to get last month date - CR XIr2

    Post Author: olesco
    CA Forum: Formula
    I need to pass the value (#of units) from the subreport to the main report u2013 I know how to do that but my problem is I donu2019t know what formula should I put in my subreport  to get last month date.
    Both main report and subreport have a date parameter (Field link - {?DatePrompt}. What I need is when I fill in the current month date to the main report the subreport should process the last moth date.
    Main report u2013 Date Range (2007-10-1) (2007-10-31) - result  #of units = 22
    u201CRecord Selection Formula Editor
          DateRecd = {@DatePrompt} &#91;i.e. current month&#93;
    Subreport u2013 should have data from last month - result  #of units = 25
    u201CRecord Selection Formula Editor
          DateRecd < {@DatePrompt} &#91;last month&#93;   ??????
    There are   22 3 units this month and   25  units last month.
    Any help is greatly appreciated.

    Post Author: SKodidine
    CA Forum: Formula
    DateRecd in dateadd('m',-1,minimum({@DatePrompt})) to dateadd('m',-1,maximum({@DatePrompt}))

  • How to get  the actual data in ALV report

    I am doing some upgradation work   in that i am using Submit  & And return and  also i am using some function modules like LIST FROM MEMORY , LIST TO TXT wnd WRITE LIST , it gives output in normal list format , But i need to print in ALV report .
    With the use of set table for 1st display i got the  ALV report   but not with actual data, (some junk value is showing) , So can any 1 suggest me how to get  the  actual data in ALV report, With the use of  Any Function Module or with Coding,
    with regards,

    Hi Saravana
    I am sure you must be getting the values in tables of table parameters from every FM.
    consolidate the values from tables of all FMs in one table and built ALV for that table only.
    I hope this way you can show the actual data in ALV.
    thanks
    Lalit

Maybe you are looking for

  • "Configfree has stopped working" error on Satellite L300 running Win7_32bit

    Full text message *ConfigFree Task Tray Menu has stopped working* Every time the USB modem (Huawei E352 HSPA USB stick) connects this error appears. Running Win7 Ultimate 32 bit. Did Google search: some reckon it's a virus, others reckon it's a hardw

  • Is it possible for non-sap systems to consume BDOCs without conversion?

    Hi All, I am new to CRM. I use SAP Jco API's to connect to SAP from my java application. Similarly now i want to connect to CRM. Basically the required is to consume or send BDOC across Java application (non-sap system) and SAP CRM. 1. Is there a way

  • Recovered deleted iPhoto library is in wrong format?

    My iPhoto library was deleted so I used Disk Drill Pro and seemingly successfully recovered them. I recovered them and saved them to a USB drive but when I click the recovered library, iPhoto says it doesn't recognize the format. This is what the con

  • Creating an inventory directory

    This thread is a follow on from the issue that I am having with The 11.2.0.3 installer hanging Installer hanging on selecting Desktop Class I had a look at the Installactions*.log file and installation appears to be hanging at the point of creating t

  • BUG?: WebDAV access very very very slow with rsync -vrt

    rsync -vrt --progress dir/ /Volumes/website.com/dir Volume was mounted with Finder to an account on hostmonster.com I assume the reason is refected in the system.log output, but I might be wrong. Sep 13 17:13:41 adsl-116 webdavfs_agent[3362]: unexpec