Overview of Time and Date Functions
The time and date functions of DWS are used to add or subtract dates, obtain the current time, format date display, and extract the year, month, and day. These functions are widely used in data analysis, schedule management, and financial reports, helping you process data more efficiently and accurately.
|
Type |
Function |
Description |
|---|---|---|
|
Basic time and date functions |
Returns the day of a given date or time. |
|
|
Returns the week of a given date or time. Monday is the start day of a week. |
||
|
Returns the week number in the year of the specified datetime. |
||
|
Returns the month of a given date or time. |
||
|
Returns the quarter to which the date or time belongs. |
||
|
Returns the year of a given date or time. |
||
|
Returns the year and the week number in the year corresponding to a given date or time. |
||
|
Returns the week of a given date or time. Sunday is the start day of a week. |
||
|
Returns the number of days in the month of a given date or time. |
||
|
Returns the day of a given date or time in the year. |
||
|
Returns the week number of a given date or time in the year. It is equivalent to week(date, 3). |
||
|
Creates a date based on the given year and day of the year. |
||
|
Generates a time value based on the given hour, minute, and second. |
||
|
Returns the hour value in a timestamp. |
||
|
Returns the minute value in the time. |
||
|
Returns the second value in a timestamp. |
||
|
Returns the microsecond value in the time. |
||
|
Converts a Unix timestamp to the datetime type when the format string is set to the default value. |
||
|
Converts a date or time to a Unix timestamp (that is, returns the total number of seconds that have elapsed since January 1, 1970 00:00:00 UTC). |
||
|
Returns the start date and time of the current transaction. |
||
|
Returns the date or time of the last day of the month that contains date. |
||
|
Returns the earliest date that is later than its first argument (x), and that falls on the day of the week that its second argument (y) specifies. |
||
|
Returns the date value based on the given number of days. |
||
|
Returns the number of days since the year 0 based on the specified date. |
||
|
Time and date calculation functions |
Subtracts arguments and returns the difference. |
|
|
Subtracts arguments and returns the difference. |
||
|
Returns the result of a given datetime plus the time interval of a specified unit. |
||
|
Returns the result of a given datetime minus the time interval of a specified unit. |
||
|
Returns the result of a given datetime plus the time interval of a specified unit. |
||
|
Returns the result of a given datetime minus the time interval of a specified unit. |
||
|
Returns the result of a given datetime plus the time interval of a specified unit. |
||
|
Returns the result of a given datetime minus the time interval of a specified unit. |
||
|
Adds an integer interval in the unit of field (the number of seconds can be a decimal) to a datetime expression. |
||
|
Subtracts timestamp1 from timestamp2 and returns the difference in the unit of field. |
||
|
Subtracts a date from another date. |
||
|
Returns the number of days between two given dates. |
||
|
Returns the date of a given period plus N months. |
||
|
Returns the number of months between two given dates. |
||
|
Adds a specified number of months to a date. |
||
|
Time and date extraction functions |
Extracts a specified part from a date or time expression. |
|
|
date_trunc(text, timestamp with time zone | timestamp without time zone | interval) |
Truncates a time or date to the specified precision. |
|
|
Truncates a timestamp to day. |
||
|
Extracts a specified time part from a date or time expression. |
||
|
Functions for obtaining the current time and date |
Returns the current timestamp of the real-time clock. |
|
|
Returns the current date. |
||
|
Returns the current date. This function is compatible with MySQL. |
||
|
Returns the current time. |
||
|
Returns the current time. |
||
|
Returns the current date and time (start time of the current transaction). |
||
|
Returns the current time. |
||
|
Returns the current date and time. |
||
|
Returns the current date and time (start time of the current transaction). |
||
|
Returns the current date and time of the system. |
||
|
Returns the current date and time. |
||
|
Returns the system date and time when the current transaction starts. |
||
|
Time and date formatting functions |
Converts a date into a string in the format specified by fmt. |
|
|
Converts a date into a string in the format specified by fmt. |
||
|
Converts a string of the date or time type to a value of the date type according to the provided display format. |
||
|
Converts a string of the time type to a value of the time type according to the provided display format. |
||
|
Other time and date processing functions |
Sets the unit of time interval to 30 days. |
|
|
Sets the unit of time interval to 24 hours. |
||
|
Adjusts the interval using justify_days and justify_hours. |
||
|
Converts a numeric value into an INTERVAL DAY TO SECOND literal based on a specified unit. |
||
|
Description: Converts the datetime value from the time zone provided by from_tz (text) to the time zone provided by to_tz (text), and returns the converted datetime. |
||
|
Checks whether the date is finite. |
||
|
Checks whether a timestamp is valid. |
||
|
Checks whether an interval is valid. |
||
|
Returns the server thread delay. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot