In my dataset, I have a start datetime field and an end datetime field.
I need to determine if there is a Saturday in this date range (would only need to check for one occurrence as this date range is max 3 days).
For example the below date range - there is one Saturday (the 18th) in this range. I would like to set some sort of flag to indicate that there is a Saturday in the range.
begin_date - 2023-03-17 08:04:02.000, end_date - 2023-03-20 23:17:30.000
Thank you
1条答案
按热度按时间envsm3lx1#
You can do a function like this:
I got it down to 4 conditions to cover the various cases, maybe someone can optimize a couple of them away, but dating are hard.
You can also convert it to inline function to get better performance or just reuse the case when. Note that i cast the dates to DATE, since times are irrelevant here