Skip to Content
Former Member

# How do I calculate some date?

Hello,

I need a variable that should keep the <next_tuesday>.

Not a certain one, but a general one.

Any clues?

Thank you.

##### Add comment
10|10000 characters needed characters exceeded

### 6 Answers

• Best Answer
Posted on Aug 23, 2007 at 03:28 PM

Use DAY_IN_WEEK to pass a date and get the day of the week. 1 is Monday, 2 is Tuesday and 7 is Sunday. Once you know one Tuesday's date, then you can always add 7 days to it, to get the next Tuesday. So if I am executing my program today (Thrusday), using this function module gives me a 4, that way I know that today is Thrusday and I go back 2 days to get the date of Tuesday and then add 7 to get the next Tuesday, or you can just add 5.

##### Add comment
10|10000 characters needed characters exceeded
• Hi,

May be this way

```call function 'DAY_ATTRIBUTES_GET'
exporting
DATE_FROM = sy-datum
date_to = sy-datum
TABLES
DAY_ATTRIBUTES = it_days.
if sy-subrc eq 0.
read table it_days into x_days index 1.
if sy-subrc eq 0.
if x_days-weekday > 2.
v_diffdays = 9 - x_days-weekday.
else.
v_diffdays = 2 - x_days-weekday.
endif.
next_tuesday = sy-datum + v_diffdays
endif.
endif.
```

• Former Member
Posted on Aug 23, 2007 at 03:05 PM

Hi,

try this:

DATA: DATE LIKE SY-DATUM.

DATA: DAY LIKE SCAL-INDICATOR.

DATA: DAY_TEXT LIKE RNPB2-DAY_TXT.

*

DATe = SY-DATUM.

*

DO.

*

CALL FUNCTION 'ISH_GET_DAY_OF_WEEK'

EXPORTING

DATE = DATE

IMPORTING

DAY = DAY

DAY_TXT = DAY_TEXT.

*

IF DAY = 2.

WRITE: / DATE, DAY, DAY_TEXT.

EXIT.

ENDIF.

*

DATE = DATE + 1.

*

ENDDO.

regards, Dieter

##### Add comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Aug 23, 2007 at 03:00 PM

Hi Anda,

Use function module <b>DAY_ATTRIBUTES_GET</b> to get the attributes of dates for the specified range of dates for a factory/holiday calendar.

Give the DATE_FROM as a date and give the DATE_TO as 7 days to the DATE_FORM. Query on the DAY_ATTRIBUTES table for your requirement.

Thanks,

Vinay

##### Add comment
10|10000 characters needed characters exceeded
• Posted on Aug 23, 2007 at 03:00 PM

Hi,

Can you please give some more details of your requirement

aÂ®

##### Add comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Aug 23, 2007 at 03:16 PM

HI,

data : lv_today like sy-datum,

lv_7days like sy-datum.

data : it_days like standard table of CASDAYATTR,

x_days like casdayattr.

lv_today = sy-datum.

lv_7days = sy-datum + 7.

call function 'DAY_ATTRIBUTES_GET'

exporting

DATE_FROM = lv_today

date_to = lv_7days

TABLES

DAY_ATTRIBUTES = it_days.

if sy-subrc eq 0.

read table it_days into x_days where WEEKDAY = 2 weekday_s = 'TU'.

<b>now x_days will contain the next tuesday.</b>

endif.

##### Add comment
10|10000 characters needed characters exceeded
• Former Member
Posted on Aug 23, 2007 at 03:16 PM

I have to write a message that gives the expiration date and time , but the date should be always <next_tuesday> , because the process that gives the message when is done is weekly .

So I should put my <next_tuesday> in a parameter and calculate it somehow..I think .

##### Add comment
10|10000 characters needed characters exceeded
• Former Member

HI,

with the above code you will have the date in x_days-DATE field.. then you can wirte a message.

message e000(Messageclass) with 'Expiration date is ' x_days-date .

Thaks

mahesh