Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

date format

Former Member
0 Kudos

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?

14 REPLIES 14

Former Member
0 Kudos

jst use date = sy-datum - 1.

0 Kudos

i dont know on wat day i may run.

let us say i run 2 day i.e., friday even though i should get starting date of the week i.e, monday

0 Kudos

I understand your requirement...

Just use this FM..this returns always that week monday...

CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'

EXPORTING

date = sy-datum

IMPORTING

monday = pdat.

0 Kudos
Hi Madan,

chk this

REPORT YCHATEST2.

DATA : V_DATE LIKE SY-DATUM.

CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
 EXPORTING
   DATE          = SY-DATUM
 IMPORTING
*   WEEK          = WEEK
   MONDAY        = V_DATE.
*   SUNDAY        = SUNDAY.


WRITE : / 'First day of week is ' , V_DATE.

0 Kudos

Hi Madan..

These are the Hints:

First Call the FM <b>DATE_GET_WEEK "</b>Returns the Week No of the Given Date

Call the FM <b>WEEK_GET_FIRST_DAY</b> "Returns the First day of the week

reward if Helpful.

0 Kudos

how can i add 7 days to a date.

suppose v_date is type sy-datum

contains date as 22.10.2007.

how can i add 1 week to that date.

0 Kudos

Hi,

To add 7 days to your date

Use the function module

<b>RP_CALC_DATE_IN_INTERVAL</b>

Sample code:

DATA V_DATE TYPE SY-DATUM.

CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'

EXPORTING

DATE = SY-DATUM

DAYS = 7

MONTHS = 0

SIGNUM = '+'

YEARS = 0

IMPORTING

CALC_DATE = V_DATE.

write:/ v_date.

0 Kudos
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.

former_member189596
Active Participant
0 Kudos

Hi madam,

create select screen using sy-datum,

fetch data based on sy-daum - 1.

If useful, reward points,

Regards,

Bhaskar

Former Member
0 Kudos

You can use the FM - BWSO_DATE_GET_FIRST_WEEKDAY.

That will give the first day of the week.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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*

Former Member
0 Kudos

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.