DHMS Function

Returns a SAS datetime value from date, hour, minute, and second values.
Category: Date and Time

Syntax

Required Arguments

date
specifies a SAS expression that represents a SAS date value.
hour
is numeric.
minute
is numeric.
second
is numeric.

Details

The DHMS function returns a numeric value that represents a SAS datetime value. This numeric value can be either positive or negative.

Example

The following SAS statements produce these results:
SAS Statement
Result
dtid=dhms('01jan03'd,15,30,15);
put dtid;
put dtid datetime.;
1357054215
01JAN03:15:30:15
dtid2=dhms('01jan03'd,15,30,61);
put dtid2;
put dtid2 datetime.;
1357054261
01JAN03:15:31:01
dtid3=dhms('01jan03'd,15,.5,15);
put dtid3;
put dtid3 datetime.;
1357052445
01JAN03:15:00:45
The following SAS statements show how to combine a SAS date value with a SAS time value into a SAS datetime value. If you execute these statements on April 2, 2003 at the time of 15:05:02, it produces these results:
SAS Statement
Result
day=date();
time=time();
sasdt=dhms(day,0,0,time);
put sasdt datetime.;
02APR03:15:05:02

See Also

Functions: