Help Center/ Data Lake Insight/ Spark SQL Syntax Reference/ Built-In Functions/ Date Functions/ weekday
Updated on 2023-10-25 GMT+08:00
weekday
This function is used to return the day of the current week.
Syntax
weekday (string date)
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| date | Yes | DATE or STRING | Date that needs to be processed The following formats are supported:
|
Return Values
The return value is of the INT type.
- If Monday is used as the first day of a week, the value 0 is returned. For other weekdays, the return value increases in ascending order. For Sunday, the value 6 is returned.
- If the value of date is not of the DATE or STRING type, the error message "data type mismatch" is displayed.
- If the value of date is of the DATE or STRING type but is not in one of the supported formats, NULL is returned.
- If the value of date is NULL, NULL is returned.
Example Code
The value 2 is returned.
select weekday ('2023-08-16 10:54:36'); The value NULL is returned.
select weekday (null);
Parent topic: Date Functions
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.