Date Intervals, Formats, and Functions

Datetime and Time Formats

Table 4 lists some of the available SAS datetime and time formats. For each format, the example shows the formatted value. The value of the variable dt is '17OCT91:14:25:32'DT. You can specify the width of each format by adding w. For formats that allow a decimal value, you can specify the number of decimal digits by adding d.

Table 4: Frequently Used SAS Datetime and Time Formats

Format Value Example Description Width Range Default Width
DATETIMEw.d dt 17OCT91:14:25:32 ddmonyy: 7–40 16
hh:mm:ss.ss
DTWKDATXw. dt Thursday, 17 October day-of-week, 3–37 29
1991 dd month yyyy
HHMMw.d TIMEPART(dt) 14:26 Hour and 2–20 5
minute:
hh:mm.mm
HOURw.d TIMEPART(dt) 14 Hour: hh.hh 2–20 2
MMSSw.d HMS(0, 25:32 Minutes and 2–20 5
MINUTE(dt), seconds:
SECOND(dt)) mm:ss.ss
TIMEw.d TIMEPART(dt) 14:25:32 Time of day: 2–20 8
hh:mm:ss.ss
TODw.d dt 14:25:32 Time of day: 2–20 8
hh:mm:ss.ss


Last updated: June 19, 2025