SAS Timestamp Converter — Datetime seconds / Date days since 1960 ↔ Date

Convert SAS datetime seconds or date days since 1960-01-01 UTC ↔ human-readable dates. Hex (0x…) or decimal. Fully client-side.

Display & Settings

Results always include UTC; this controls an additional local view.
SAS datetime counts seconds; SAS date counts whole days.

Quick View

Run a conversion below to see detailed outputs here.

1) SAS Value → Date

Use the Unit selector above to choose seconds vs days.

2) Date → SAS Value

Interpreted in your current local time zone.
If an offset is provided, it will be respected.
Outputs as SAS datetime (seconds).

About SAS Time

SAS datetime counts seconds (fractional allowed) since 1960-01-01T00:00:00Z. SAS date counts whole days since 1960-01-01.

  • UNIX ↔ SAS datetime (seconds): unix = sasSec − 315,619,200; sasSec = unix + 315,619,200
  • UNIX ↔ SAS date (days): sasDays = floor(unix / 86,400) + 3,653; unix ≈ (sasDays − 3,653) × 86,400
  • Time zone & DST: Stored values are UTC-based; only display formatting changes with time zone/DST.

SAS Time: Code Snippets

Convert between SAS datetime seconds / date days and ISO-8601 dates.

JavaScript

const SAS_UNIX_OFFSET_SEC = 315_619_200; // 1960→1970
function unixToSasSeconds(unixSec){ return unixSec + SAS_UNIX_OFFSET_SEC; }
function sasSecondsToUnix(sasSec){ return sasSec - SAS_UNIX_OFFSET_SEC; }
function sasSecondsToDate(sasSec){ return new Date((sasSec - SAS_UNIX_OFFSET_SEC) * 1000); }
function dateToSasSeconds(d){ return d.getTime()/1000 + SAS_UNIX_OFFSET_SEC; }
function unixToSasDays(unixSec){ return Math.floor(unixSec/86400) + 3653; }
function sasDaysToUnix(sasDays){ return (sasDays - 3653) * 86400; }

Python

import datetime
SAS_UNIX_OFFSET_SEC = 315_619_200
def sas_seconds_to_datetime(s): return datetime.datetime.fromtimestamp(s - SAS_UNIX_OFFSET_SEC, tz=datetime.timezone.utc)
def datetime_to_sas_seconds(dt):
    if dt.tzinfo is None: dt = dt.astimezone()
    return dt.timestamp() + SAS_UNIX_OFFSET_SEC
def sas_days_to_date(d): # returns date at 00:00 UTC
    sec = (d - 3653) * 86400
    return datetime.datetime.fromtimestamp(sec, tz=datetime.timezone.utc)

5 Fun Facts about SAS Timestamps

1960 was chosen on purpose

The SAS epoch 1960-01-01 is the first leap year of that decade and sits between COBOL’s 1960 defaults and IBM mainframe calendars—handy for 60s-era data.

Epoch lore

Offset as one hex constant

The Unix ↔ SAS seconds gap is 315,619,200 seconds, a tidy 0x12D53D80. Add or subtract it to hop epochs instantly.

Converter shortcut

Days mode lands on 1970 at 3,653

SAS date day 3,653 equals 1970-01-01. Negative days walk backward: -3,653 is 1949-12-31.

Mental anchor

Fractional seconds survive round-trips

SAS datetime values can include decimals. The converter keeps sub-second precision intact when jumping between SAS seconds and ISO strings.

Precision

Excel’s cousin, different birthday

Excel’s default epoch is 1899; SAS is 1960. Converting between them requires two offsets: Excel ↔ Unix, then Unix ↔ SAS—so two hops, not one.

Interop trivia

Explore more tools