DATETIMEw. Informat

Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.
Category: Date and Time

Syntax

DATETIMEw.

Syntax Description

w
specifies the width of the input field.
Default:18
Range:13–40

Details

The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time):
dd
is an integer between 01 and 31 that represents the day of the month.
mmm
is the first three letters of the month name.
yy or yyyy
is a two-digit or four-digit integer that represents the year.
hh
is an integer between 00 and 23 that represents hours.
mm
is an integer between 00 and 59 that represents minutes.
ss.ss
is the number of seconds ranging from 00–59 with the fraction of a second following the decimal point.
DATETIMEw. requires values for both the date and the time. However, the ss.ss portion is optional.
Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
Note: SAS can read time values with AM and PM in them.

Comparisons

The DATETIMEw.d informat reads datetime values with optional separators in the form dd-mmm-yy<yy> hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy<yy> hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
The YMDDTTMw.d informat reads datetime values with required separators in the form <yy>yy-mm-dd/hh:mm:ss.ss.

Example

input date_and_time datetime20.;
Data Line
Result
----+----1----+----2
16mar12:11:23:07.4
1647516187.4
16mar2012/11:23:07.4
1647516187.4
16mar2012/11:23 PM
1647559380.0

See Also

About SAS Date, Time, and Datetime Values in SAS Language Reference: Concepts
Functions:
DATETIME Function in SAS Functions and CALL Routines: Reference
System Options:
YEARCUTOFF= System Option in SAS System Options: Reference