Reputation: 87
I want to create a function to get the last 4 days on data including today. Here's my function, what am I missing? When I run a test I got an empty table.
df.where(trunc(col("date"),"day") >= date_add(current_date(),-4))
Upvotes: 0
Views: 1459
Reputation: 42422
Try to use date_trunc
instead. trunc
only supports month and year. Also note that date_trunc
accepts arguments in the reverse order of trunc
.
df.where(date_trunc("day",col("date")) >= date_add(current_date(),-4))
Upvotes: 2