SAS Timestamp Converter: Date & Datetime Since 1960

SAS date values count days, and SAS datetime values count seconds since 1 January 1960. Use this SAS datetime converter to convert a SAS date to a calendar date—or a calendar value back to SAS—entirely in your browser.

Convert SAS values

Choose the value type

Enter either field. Date mode uses timezone-free calendar arithmetic, so midnight cannot shift to the previous or next day.

SAS Date → calendar date

Whole decimal days, explicit hex such as 0xE45, DATE9., or a SAS date literal.

Calendar date → SAS Date

Use an unambiguous four-digit year. The reverse SAS value updates immediately.

Choose SAS Date or SAS Datetime, then enter a value in either field.

Batch conversion (one value per line)


          

Advertisement

Worked SAS date and datetime examples

Use these verified anchors to identify whether a column contains days or seconds. Each button loads the value into the correct converter mode.

TypeSAS valueSAS-formatted resultTry it
SAS date001JAN1960
SAS datetime001JAN1960:00:00:00
SAS date365301JAN1970
SAS datetime31561920001JAN1970:00:00:00
Negative date-131DEC1959
Fractional datetime0.12345601JAN1960:00:00:00.123456

Core SAS conversion formulas

Unix seconds = SAS datetime − 315,619,200

SAS datetime = Unix seconds + 315,619,200

Unix days = SAS date − 3,653

SAS date = Unix days + 3,653

The seconds offset is 0x12CFF780 in hexadecimal. Floor Unix seconds only when deliberately reducing an instant to a whole calendar day; do not floor a datetime just to format it.

For Excel's 1900 date system, Excel serial = SAS date + 21,916. Excel preserves a historical, fictitious 29 February 1900 as serial 60, so conversions around that boundary need special handling.

SAS code: format, parse, extract, and combine

A FORMAT statement or PUT displays an existing numeric value. INPUT parses a character string into a numeric SAS value. They are not interchangeable.

/* Display existing numeric values */
format order_date date9. event_dt datetime23.3;
date_text = put(order_date, yymmdd10.);
datetime_text = put(event_dt, e8601dt26.6);

/* Parse character strings */
order_date = input('21DEC2011', date9.);
event_dt = input('21DEC2011:12:00:35', anydtdtm.);

/* Convert datetime to date, then display it */
order_date = datepart(event_dt);
format order_date date9.;

/* Combine a SAS date with a clock time */
event_dt = dhms(order_date, 12, 0, 35);
format event_dt datetime20.;

Use DATEPART when “convert datetime to date in SAS” means extracting the date portion. Use DHMS for the reverse operation. See the official SAS references for DATEPART and DHMS.

JavaScript and Python epoch formulas
const SAS_UNIX_OFFSET_SECONDS = 315_619_200;
const unixSeconds = sasDatetime - SAS_UNIX_OFFSET_SECONDS;
const sasDatetime = unixSeconds + SAS_UNIX_OFFSET_SECONDS;
SAS_UNIX_OFFSET_SECONDS = 315_619_200
unix_seconds = sas_datetime - SAS_UNIX_OFFSET_SECONDS
sas_datetime = unix_seconds + SAS_UNIX_OFFSET_SECONDS

Troubleshooting SAS time values

Before 1960 and missing values

Negative values are valid dates before the SAS epoch. A period or special missing value such as ., .A, or ._ is missing data, not a timestamp, and is reported rather than converted.

Date, datetime, or time?

SAS dates are days from 1960; datetimes are seconds from 1960; SAS time values are seconds since midnight. A plausible-looking wrong result usually means the wrong unit was chosen.

Fractions and Unix milliseconds

Datetime fractions represent fractions of a second. A 13-digit Unix millisecond value is not a SAS datetime; divide it by 1,000 to get Unix seconds, then add 315,619,200.

Two-digit years

Two-digit years depend on SAS YEARCUTOFF= and are intentionally rejected here. Use four digits to remove ambiguity.

Timezone-naive data

Traditional SAS datetime numbers do not carry timezone metadata. Match this tool's interpretation setting to the source system, especially across daylight-saving transitions.

Excel imports

Confirm whether Excel supplied a serial date, formatted text, or a timezone-adjusted datetime. For the 1900 system, the SAS-to-Excel offset is 21,916, with the serial-60 leap-year caveat.

Frequently asked questions

What do SAS date and datetime values mean?

A SAS date is the number of days from 1 January 1960. A SAS datetime is the number of seconds from 1 January 1960 at 00:00:00. Values before the epoch are negative.

Are SAS datetime values UTC?

Not inherently. A traditional SAS datetime is a numeric count with no time-zone metadata. Interpret it in UTC, local time, or the source system's named time zone as appropriate.

How do I convert a SAS datetime to a SAS date?

In SAS, use DATEPART(datetime_value) to extract the SAS date value, then apply a date format such as DATE9. Formatting alone does not change a datetime value into a date value.

How do Unix and SAS epochs differ?

The SAS epoch is 1 January 1960 and the Unix epoch is 1 January 1970. Subtract 315,619,200 from a SAS datetime to get Unix seconds, or subtract 3,653 from a SAS date to get Unix days.

Do negative and fractional SAS values work?

Yes. Negative values represent dates before 1960. SAS datetime fractions are accepted and the typed precision is retained in numeric and formatted output; SAS date mode requires whole days.

Why is my result one day or one hour off?

A one-day error often means a datetime was treated as a date, or a timezone shifted midnight. A one-hour error usually indicates a timezone or daylight-saving interpretation mismatch. Choose the source timezone explicitly; date mode uses timezone-free calendar arithmetic.

Methodology and sources

This independent converter is not affiliated with or endorsed by SAS Institute Inc. It uses calendar arithmetic from the 1 January 1960 epoch, rejects values outside the browser's representable date range instead of clamping them, and retains typed fractional digits separately from JavaScript's millisecond-only Date object.

Definitions, supported SAS calendar range, formats, and timezone behavior were reviewed against official SAS documentation: date, time, and datetime values, time zones in SAS, formats by category, DATEPART, and DHMS.

Published validation cases: 0 → 01JAN1960, 3653 → 01JAN1970, and 315619200 → 01JAN1970:00:00:00, checked against SAS epoch definitions and SAS DATE9./DATETIME output conventions. Last reviewed: 16 July 2026.

Explore more tools