To use the SAS Date Calculator/Converter, enter a date value in the first text box. The unformatted date value (i.e., the number of days since 1/1/1960) that SAS associates with that number will appear in the second text box. The calculator also works in reverse.

The SAS Datetime Calculator works similarly but calculates Datetimes.

**To convert dates and datetimes in SAS**, use code like this:

/*print
date formatted as number*/

DATA _NULL_;

d =
INPUT('21DEC11'd, best12.);

PUT d;

RUN;

/*print
number formatted as
date*/

DATA _NULL_;

d = 18982;

FORMAT d
date9.;

PUT d;

RUN;

/*print
datetime formatted as
number*/

DATA _NULL_;

dt = INPUT('21DEC11
12:00:35'dt, best12.);

PUT dt;

RUN;

/*print
number formatted as
datetime*/

DATA _NULL_;

dt =
1640088035;

FORMAT dt
datetime.;

PUT dt;

RUN;

**To convert a date in Excel**, subtract 21,916:

**To convert a datetime in Excel**, subtract 21,916, then multiply by 86,400: