Date Functions¶
Quick Reference¶
| Function | Description |
|---|---|
CURRENT_DATE | Returns the current date with time set to midnight. |
CURRENT_DATE | Returns the current date with time set to midnight. |
CURRENT_TIMESTAMP | Returns the current date and time. |
CURRENT_TIMESTAMP | Returns the current date and time. |
DATEDIFF | Returns the difference in days between two dates. |
DATEDIFF | Returns the difference in days between two dates. |
DATE_ADD | Adds a given number of days to a date. |
DATE_ADD | Adds a given number of days to a date. |
DATE_SUB | Subtracts a given number of days from a date. |
DATE_SUB | Subtracts a given number of days from a date. |
EXTRACT_DAY | Extracts the day of month from a date. |
EXTRACT_DAY | Extracts the day of month from a date. |
EXTRACT_MONTH | Extracts the month (1-12) from a date. |
EXTRACT_MONTH | Extracts the month (1-12) from a date. |
EXTRACT_YEAR | Extracts the year component from a date. |
EXTRACT_YEAR | Extracts the year component from a date. |
Function Details¶
CURRENT_DATE¶
Returns the current date with time set to midnight.
Returns: DATE - The current date with time zeroed.
Examples:
CURRENT_DATE¶
Returns the current date with time set to midnight.
Returns: DATE - The current date with time zeroed.
Examples:
CURRENT_TIMESTAMP¶
Returns the current date and time.
Returns: DATE - The current date and time.
Examples:
CURRENT_TIMESTAMP¶
Returns the current date and time.
Returns: DATE - The current date and time.
Examples:
DATEDIFF¶
Returns the difference in days between two dates.
Parameters:
| Name | Type | Description |
|---|---|---|
date1 | DATE | The first date. |
date2 | DATE | The second date. |
Returns: NUMBER - Number of days between date1 and date2.
Examples:
DATEDIFF¶
Returns the difference in days between two dates.
Parameters:
| Name | Type | Description |
|---|---|---|
date1 | DATE | The first date. |
date2 | DATE | The second date. |
Returns: NUMBER - Number of days between date1 and date2.
Examples:
DATE_ADD¶
Adds a given number of days to a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The original date. |
days | NUMBER | Number of days to add. |
Returns: DATE - The resulting date after addition.
Examples:
DATE_ADD¶
Adds a given number of days to a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The original date. |
days | NUMBER | Number of days to add. |
Returns: DATE - The resulting date after addition.
Examples:
DATE_SUB¶
Subtracts a given number of days from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The original date. |
days | NUMBER | Number of days to subtract. |
Returns: DATE - The resulting date after subtraction.
Examples:
DATE_SUB¶
Subtracts a given number of days from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The original date. |
days | NUMBER | Number of days to subtract. |
Returns: DATE - The resulting date after subtraction.
Examples:
EXTRACT_DAY¶
Extracts the day of month from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER - The day of the month.
Examples:
EXTRACT_DAY¶
Extracts the day of month from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER - The day of the month.
Examples:
EXTRACT_MONTH¶
Extracts the month (1-12) from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER
Examples:
EXTRACT_MONTH¶
Extracts the month (1-12) from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER
Examples:
EXTRACT_YEAR¶
Extracts the year component from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER - The year component.
Examples:
EXTRACT_YEAR¶
Extracts the year component from a date.
Parameters:
| Name | Type | Description |
|---|---|---|
date | DATE | The date to extract from. |
Returns: NUMBER - The year component.
Examples: