@Shmuel wrote:
Excel holds a date as number of days past since and including 01/01/1900
(= 1 as a number);
SAS holds the date as number of days past since and excluding 01/01/1960
(= 0 as a number);
If you enter any date in an excel cell and in sas variable and check the numeric difference - it is a constant.
You can convert the numeric value using next formulas:
converting date/time values from Excel to SAS.
SAS_date = Excel_date - 21916;
SAS_time = Excel_time * 86400;
SAS_date_time = (Excel_date_time - 21916) * 86400;
There is no need to remember "magic" numbers. Just use DATE ('30DEC1899'd) or TIME ('24:00:00't) literals.
257 data _null_;
258 offset = '30DEC1899'd ;
259 seconds = '24:00:00't ;
260 put (offset seconds) (= comma11.);
261 run;
offset=-21,916 seconds=86,400
PS The reason to use 30th instead of 31st is that Excel treats 1900 as a leap year (which it isn't).