Skip to Content
author's profile photo Former Member
Former Member

how to assign date to variable

hi,

how to assign date field to a variable??

thanks and regards,

harini.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Posted on Dec 18, 2008 at 06:14 AM

    Hi Harini,

    Use:-

    DATA : date like sy-datum.
    
    date = sy-datum.
    WRITE : / date.
    

    or

    PARAMETERS : date like sy-datum.
    
    WRITE : / date.
    

    In the first case, date will be assigned the current system date.

    In this second case, enter any date of format dd.mm.yyyy or ddmmyyyy, you will get the result.

    For comparing two dates:-

    PARAMETERS : date1 like sy-datum,
                 date2 like sy-datum.
    
    IF date1 GT date2. "comparing the dates
      "code
    ELSE.
      "code
    ENDIF.
    

    Hope this solves your problem.

    Thanks & Regards,

    Tarun Gambhir

    Edited by: Tarun Gambhir on Dec 18, 2008 11:44 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Just i have gone through this postings.

      I have one date.

      In select options when iam selecting date it is showing MMDDYYYY Format.

      But my requirement is it should have to show like DDMMYYYY.

      tHANKS IN ADVANCE.

      rEGARDS,

      Vinay

      Edited by: vinay raj on Dec 18, 2008 12:13 PM

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:09 AM

    HI

    guess u r new to ABAP. USe F1 and u have SAP Docu for your help .

    data : v_date type sy-datum.

    v_date = sy-datum.

    regards,

    Ramya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:09 AM

    Take variable of type char 8.

    data: date(8).

    move sy-datum to date.

    Regards,

    Aparna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:09 AM

    HI,

    Data : Date1 type sy-datum,

    DATe2 type char10.

    two ways to assign date value...

    1. Date1 = sy-datum

    2. write sy-datum to Date2.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:10 AM

    Hi,

    Decalre a variable of type sy-datum and assign the date to it.

    Rgds,

    Vartika

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 18, 2008 at 06:10 AM

    Hi Harini,

    Data : date type sy-datum.

    move sy-datum to date

    or date = sy-datum

    Please be clear of what you are looking.

    data : var type i value 100.

    data : char type string.

    char = 'HARINI*

    Regards

    Ramchander Rao.K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:11 AM

    Hi,

    Do the follwing way.

    Data : date type sy-datum.

    date = sy-datum.

    regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 06:11 AM

    Hi,

    You can do it as :

    Data : dat1 type sy-datum,

    dat2 type sy-datum.

    you can do it the same way as you compare the two variables using =, >, <.

    Thanks & regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.