Application Development and Automation 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: 
Read only

Problem with Date

Former Member
0 Likes
699

Hi guys,

I have date1 = sy-datum, which is stored as 20090217 (today's date).

Now, x is a variable which has for suppose '17' now.

In date2, i want to have value which is 17 days earlier, dat is '20090201'.

How can I write the code to fulfill my requiremnt, I havent worked on DATE fields earlier.

So, Iam getting confused.

I know I can find difference between two dates fields by simply subtracting them.

But, my requirement is different.

Waiting for ur suggestuions , guys......

Thanks,

Shivaa...

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
622

date2 = date1 - x.

Easy, wasn't it.

5 REPLIES 5
Read only

matt
Active Contributor
0 Likes
623

date2 = date1 - x.

Easy, wasn't it.

Read only

Former Member
0 Likes
622

Thanks, man........i didnt think it was so easy........

Read only

0 Likes
622

Read only

Former Member
0 Likes
622

Hi Shiva

Just Try FM:- HR_SGPBS_ADD_TIME_TO_DATE

Eg:-

DATA: L_DATE TYPE SY-DATUM.

CALL FUNCTION 'HR_SGPBS_ADD_TIME_TO_DATE'

EXPORTING

I_IDATE = SY-DATUM

I_TIME = '-16'

I_IPRKZ = 'D'

IMPORTING

O_IDATE = L_DATE

EXCEPTIONS

INVALID_PERIOD = 1

INVALID_ROUND_UP_RULE = 2

INTERNAL_ERROR = 3

OTHERS = 4.

Output:-

L_DATE = 20090201

Read only

0 Likes
622

Thats good fm wonderful i will use it in future