Date and Time Operators
DateFromMDY
creates a date value
from separate month, day, and year values. The first value specifies
the month as a number between 1–12. The second value specifies
the day as a number between 1–31. The third value specifies
the year as a four-digit number.
For example, (1,15,2013)
returns 15JAN2013.
DateFromYQ
creates a date value
from separate year and quarter values. The first value specifies the
year as a four-digit number. The second value specifies the quarter
as a number between 1–4.
For example, (2013,1)
returns 01JAN2013.
Note: The date is generated using
the first day of each quarter.
DatePart
converts a datetime
value to a date value.
For example, January
15, 2013 05:15 PM returns 15JAN2013.
DateTimeFromDateHMS
creates a datetime
value from a date value and separate hour, minute, and second values.
The first value specifies the date. The second value specifies the
hour as a number between 0–23. The third value specifies the
minute as a number between 0–59. The fourth value specifies
the second as a number between 0–59.
For example, (15JAN2013,
17, 15, 23) returns January 15, 2013 05:15:23 PM
DateTimeFromTimeMDY
creates a datetime
value from a time value and separate month, day, and year values.
The first value specifies the time. The second value specifies the
month as a number between 1–12. The third value specifies the
day as a number between 1–31. The fourth value specifies the
year as a four-digit number.
For example, (05:15:23
PM, 1, 15, 2013) returns January 15, 2013 05:15:23 PM.
DayOfMonth
returns the day of
the month from a date value as a number between 1–31.
For example, 15JAN2013
returns 15.
DayOfWeek
returns the day of
the week from a date value as a number between 1–7 (1 is Sunday.)
For example, 15JAN2013
returns 3 (Tuesday.)
DayOfYear
returns the day of
the year from a date value as a number between 1–366.
For example, 15FEB2013
returns 46.
Hour
returns the hour from
a time or datetime value as a number between 0–23.
For example, 05:15:23
PM returns 17.
Minute
returns the minute
from a time or datetime value as a number between 0–59.
For example, 05:15:23
PM returns 15.
Month
returns the month from
a date value as a number between 1–12.
For example, 15JAN2013
returns 1.
Now
creates a datetime
value from the current date and time.
Quarter
returns the quarter
from a date value as a number between 1–4.
For example, 15AUG2013
returns 3.
Second
returns the second
from a time or datetime value as a number between 0–59.
For example, 05:15:23
PM returns 23.
TimeFromHMS
creates a time value
from separate hour, minute, and second values. The first value specifies
the hour as a number between 0–23. The second value specifies
the minute as a number between 0–59. The third value specifies
the second as a number between 0–59.
For example, (17,15,23)
returns 05:15:23 PM.
TimePart
converts a datetime
value to a time value.
For example, January
15, 2013 05:15:23 PM returns 05:15:23 PM.
WeekNumber
returns the week of
the year as a number between 1–53, where week 2 begins on the
second Sunday of the year.
For example, 04AUG2013
returns 31.
Year
returns the year from
a date value as a four-digit number.
For example, 15JAN2013
returns 2013.
Copyright © SAS Institute Inc. All rights reserved.