Calendar Functions

Calendar functions manipulate data of the data types DATE and DATETIME based on a calendar year.

Function Example Description

Current_Date

Current_Date

Returns the current date.

Current_Time

Current_Time(3)

Returns the current time to the specified number of digits of precision, for example: HH:MM:SS.SSS

If no argument is specified, the function returns the default precision.

Current_TimeStamp

Current_TimeStamp(3)

Returns the current date/timestamp to the specified number of digits of precision.

DayName

DayName(Order_Date)

Returns the name of the day of the week for a specified date expression.

DayOfMonth

DayOfMonth(Order_Date)

Returns the number corresponding to the day of the month for a specified date expression.

DayOfWeek

DayOfWeek(Order_Date)

Returns a number between 1 and 7 corresponding to the day of the week for a specified date expression. For example, 1 always corresponds to Sunday, 2 corresponds to Monday, and so on through to Saturday which returns 7.

DayOfYear

DayOfYear(Order_Date)

Returns the number (between 1 and 366) corresponding to the day of the year for a specified date expression.

Day_Of_Quarter

Day_Of_Quarter(Order_Date)

Returns a number (between 1 and 92) corresponding to the day of the quarter for the specified date expression.

Hour

Hour(Order_Time)

Returns a number (between 0 and 23) corresponding to the hour for a specified time expression. For example, 0 corresponds to 12 a.m. and 23 corresponds to 11 p.m.

Minute

Minute(Order_Time)

Returns a number (between 0 and 59) corresponding to the minute for a specified time expression.

Month

Month(Order_Time)

Returns the number (between 1 and 12) corresponding to the month for a specified date expression.

MonthName

MonthName(Order_Time)

Returns the name of the month for a specified date expression.

Month_Of_Quarter

Month_Of_Quarter(Order_Date)

Returns the number (between 1 and 3) corresponding to the month in the quarter for a specified date expression.

Now

Now()

Returns the current timestamp. The Now function is equivalent to the Current_Timestamp function.

Quater_Of_Year

Quarter_Of_Year(Order_Date)

Returns the number (between 1 and 4) corresponding to the quarter of the year for a specified date expression.

Second

Second(Order_Time)

Returns the number (between 0 and 59) corresponding to the seconds for a specified time expression.

TimeStampAdd

TimeStampAdd(SQL_TSI_MONTH, 12,Time."Order Date")

Adds a specified number of intervals to a timestamp, and returns a single timestamp.

Interval options are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR

TimeStampDiff

TimeStampDiff(SQL_TSI_MONTH, Time."Order Date",CURRENT_DATE)

Returns the total number of specified intervals between two timestamps.

Use the same intervals as TimeStampAdd.

Week_Of_Quarter

Week_Of_Quarter(Order_Date)

Returns a number (between 1 and 13) corresponding to the week of the quarter for the specified date expression.

Week_Of_Year

Week_Of_Year(Order_Date)

Returns a number (between 1 and 53) corresponding to the week of the year for the specified date expression.

Year

Year(Order_Date)

Returns the year for the specified date expression.