Skip to Content
avatar image
Former Member

date format

hello frnds,

my requirement is like this.

i want run a report. if i run the report on tuesday(15-03-07) the date should start from monday(14-03-07).

ho w can in achieve this functionality?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Oct 26, 2007 at 09:54 AM

    jst use date = sy-datum - 1.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member
      Hi Madan,
      
      chk this
      
      REPORT YCHATEST2.
      
      DATA : V_DATE1 LIKE SY-DATUM,
             V_DATE2 LIKE SY-DATUM.
      
      V_DATE1 = SY-DATUM + 7.
      
      CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
       EXPORTING
         DATE          = V_DATE1
       IMPORTING
      *   WEEK          = WEEK
         MONDAY        = V_DATE2.
      *   SUNDAY        = SUNDAY.
      
      
      WRITE : / 'First day of week is ' , V_DATE2.
  • avatar image
    Former Member
    Oct 26, 2007 at 09:56 AM

    Hi madam,

    create select screen using sy-datum,

    fetch data based on sy-daum - 1.

    If useful, reward points,

    Regards,

    Bhaskar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2007 at 10:05 AM

    You can use the FM - BWSO_DATE_GET_FIRST_WEEKDAY.

    That will give the first day of the week.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2007 at 10:06 AM

    Hi Madan,

    If you want the Start Date to be the 1st day of the week on which you run the report, then you can use the following FMs:

    DATE_GET_WEEK: To get the week in which a date lies.

    WEEK_GET_FIRST_DAY :To return first day for a particular week

    Reward points for useful answers.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2007 at 10:07 AM

    Hi,

    PARAMETERS: p_date TYPE sy-datum.

    DATA: v_wotnr TYPE p.

    INITIALIZATION.

    p_date = sy-datum.

    DO.

    CALL FUNCTION 'DAY_IN_WEEK'

    EXPORTING

    datum = p_date

    IMPORTING

    wotnr = v_wotnr.

    IF v_wotnr = 1.

    EXIT.

    ELSE.

    p_date = p_date - 1.

    ENDIF.

    ENDDO.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2007 at 10:08 AM

    use the below FM: it will always give you the monday,

    CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'

    EXPORTING

    date = sy-datum

    IMPORTING

    monday = l_monday.

    *reward if solved*

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2007 at 10:15 AM

    Hi,

    Please use the FM 'DATE_COMPUTE_DAY'.

    With this FM you can get the day of the week using the current date.

    for e.g. 0 stands for Monday,1 for Tuesday, 2 for Wednesday,3 for Thursday.

    Once you get the day then you can subtract the exact no of days to get the get of Monday.

    Hope it was useful.

    Thanks,

    Sandeep.

    Add comment
    10|10000 characters needed characters exceeded