Date and time functions perform operations on DATE, TIME, TIMESTAMP, and TIMESTAMP WITH TIME ZONE data types.
SQL Anywhere includes compatibility support for Transact-SQL date and time types, including DATETIME and SMALLDATETIME. These Transact-SQL data types are implemented as domains over the native SQL Anywhere TIMESTAMP data type.
Many of the date functions use dates built from date parts. The following table displays allowed values of date parts.
When using date and time functions, you can specify a minus sign to subtract from a date or time. For example, to get a timestamp from 31 days ago, you can execute the following:
SELECT DATEADD(day, -31, NOW());
|Week||WK||1-54. Weeks begin on Sunday. A 54-week year occurs in leap years that start on a Saturday.|
|Weekday||DW||1-7 (Sunday = 1, ..., Saturday = 7)|
|Microsecond||MCS or US||0-999999|
|Calyearofweek||CYR||1-9999. The year in which the week begins. The week containing the first few days of the year may have started in the previous year, depending on the weekday on which the year started. Years starting on Monday through Thursday have no days that are part of the previous year, but years starting on Friday through Sunday start their first week on the first Monday of the year.|
1-53. The week number within the year that contains the specified date.
For more information about the ISO week system and the ISO 8601 date and time standard, see http://en.wikipedia.org/wiki/ISO_week_date.
|Caldayofweek||CDW||1-7. (Monday = 1, ..., Sunday = 7)|
|TZOffset||TZ||-840 to 840|
The following date and time functions are available:
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|