‎2011 Jun 22 4:12 PM
Hi all,
I am looking at a sample code that converts a date into a number format ( that is generally achieved by using the DATE() formula in excel ). For example '12/2/2011' would be '40879'.
How could we achieve this ?
Regards
Snehith
‎2011 Jun 22 6:32 PM
Hi..
We know that Excel manages dates as serial numbers.
This means that: integer 1 is January 01/01/1900 and integer 2,958,465 is December 31/12/9999. This serial number system (1 to 2,958,465) is referred as Excel Date-Time Code...
So if you do something like this:
DATA: dat TYPE sy-datum.
DATA: cnumlow TYPE i,
datlow TYPE sy-datum VALUE '18991230'. "I think you get 2 days too much with this conversion, i.e. the epoch date would have to be moved back to DateTime(1899, 12, 30). This is due to Excel's leap year bug I assume
dat = '20090505'.
write dat.
cnumlow = dat - datlow.
write cnumlow.
You should see serial number value of 05/05/2009 in cnumlow that is 39938..
Hope to help, bye!
‎2011 Jun 22 5:09 PM
Hi Snehith,
Excel computes the days elapsed from January 1st, 1900.
So you could just use function module ISB_DAYS_BETWEEN_TWO_DATES with IP_DATE_FROM = '01.01.1900'.
I hope this helps. Kind regards,
Alvaro
‎2011 Jun 22 5:17 PM
Hello Alvaro Vidal-Abarca ,
Can you explan what parameter that we need to pass for the field "IP_SZBMETH".
I am not getting proper results.
Thanks,
Greetson
‎2011 Jun 23 8:15 AM
Hi Greetson,
you may populate IP_SZBMETH = '0'.
Kind regards,
Alvaro
‎2011 Jun 22 6:32 PM
Hi..
We know that Excel manages dates as serial numbers.
This means that: integer 1 is January 01/01/1900 and integer 2,958,465 is December 31/12/9999. This serial number system (1 to 2,958,465) is referred as Excel Date-Time Code...
So if you do something like this:
DATA: dat TYPE sy-datum.
DATA: cnumlow TYPE i,
datlow TYPE sy-datum VALUE '18991230'. "I think you get 2 days too much with this conversion, i.e. the epoch date would have to be moved back to DateTime(1899, 12, 30). This is due to Excel's leap year bug I assume
dat = '20090505'.
write dat.
cnumlow = dat - datlow.
write cnumlow.
You should see serial number value of 05/05/2009 in cnumlow that is 39938..
Hope to help, bye!