0

I'm trying to get the day of the week from a given date in pyspark could anyone help me ?

dt = dt.withColumn("week_day_number", date_format(col("TRANSACTION_DATE"), "u"))
FObersteiner
  • 22,500
  • 8
  • 42
  • 72
  • did you have a look at [How to get the weekday from day of month using pyspark](https://stackoverflow.com/q/38928919/10197418)? – FObersteiner Oct 05 '21 at 14:26

1 Answers1

0

I'm trying to get the day of the week from a given date ..

See here.

(Once you have a datetime instance just call weekday())

Monday is 0 and Sunday is 6

import datetime

print(datetime.datetime.today().weekday())
balderman
  • 22,927
  • 7
  • 34
  • 52