EXAMPLE - Day of Week Functions

This example illustrates how you can apply functions to derive day-of-week values out of a column of Datetime type:

  • WEEKDAY - returns numeric value for the day of the week for source Datetime values. See WEEKDAY Function.
  • DATEFORMAT - can be used to format Datetime values in many different ways. See DATEFORMAT Function.

Source:

myDate
10/30/17
10/31/17
11/1/17
11/2/17
11/3/17
11/4/17
11/5/17
11/6/17


Transform:

The following generates a numeric value for the day of week in a new column:

derive value: WEEKDAY (myDate) as:'weekNum'

The following generates a full text version of the name of the day of the week:

derive value:DATEFORMAT(myDate, 'EEEE') as:'weekNameFull'

The following generates a three-letter abbreviation for the name of the day of the week:

derive value:DATEFORMAT(myDate, 'EEE') as:'weekNameShort'

Results:

myDateweekNumweekNameFullweekNameShort
10/30/171MondayMon
10/31/172TuesdayTue
11/1/173WednesdayWed
11/2/174ThursdayThu
11/3/175FridayFri
11/4/176SaturdaySat
11/5/177SundaySun
11/6/171MondayMon
Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Dataprep Documentation