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

Issue with the date

Former Member
0 Likes
639

Hi Experts,

If I execute the following code i am getting 32757 for cdays. Please tell me the reason or the calculation behind this.

REPORT ZTEST .

data: z_datum type d,

erdat type d,

cdays(5) type n.

z_datum = sy-datum.

cdays = z_datum - erdat.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

u r getting the result as number of days between those two dates.

if u want to get in

Use this FM <b>HR_HK_DIFF_BT_2_DATES</b> to get the difference between dates in Years, Months and Days by specifying OUTPUT_FORMAT parameter.

If its 01, u vl get the differrnce in years,

02 - Months

03 - days.

Hope this hint may help u.

Regards,

Sujatha.

Hi Experts,

If I execute the following code i am getting 32757 for cdays. Please tell me the reason or the calculation behind this.

REPORT ZTEST .

data: z_datum type d,

erdat type d,

cdays(5) type n.

z_datum = sy-datum.

cdays = z_datum - erdat.

5 REPLIES 5
Read only

h_senden2
Active Contributor
0 Likes
605

that's correct ! You are calculating the number of days between the current date (sy-datum) and the initial date (???).

regards,

Hans

Read only

Former Member
0 Likes
605

erdat is 00000000.

sy-datum = 20070321

so 32757 days have passed after the first day in AD.

Regards,

Ravi

Read only

Former Member
0 Likes
605

chk this , it will give 732757 no of days , divide this by 365 , it will give 2007 years till now

REPORT YCHATEST.

DATA: Z_DATUM TYPE D,

ERDAT TYPE D,

<b>CDAYS(7) TYPE N.</b>

Z_DATUM = SY-DATUM.

CDAYS = Z_DATUM - ERDAT.

WRITE : CDAYS.

Read only

Former Member
0 Likes
606

u r getting the result as number of days between those two dates.

if u want to get in

Use this FM <b>HR_HK_DIFF_BT_2_DATES</b> to get the difference between dates in Years, Months and Days by specifying OUTPUT_FORMAT parameter.

If its 01, u vl get the differrnce in years,

02 - Months

03 - days.

Hope this hint may help u.

Regards,

Sujatha.

Read only

Former Member
0 Likes
605

hi Viven,

Hope u understood my answer , You have given the length of CDAYS as 5 , thats why it is not giving the correct number , increase the length to 7

DATA : CDAYS(7) TYPE N.

So you will get CDAYS as 732757 / 365 = 2007 Years till now which is true