Skip to content
Advertisement

Rank Date based on today’s date

I have a simple date dimension,

I’m attempting to write a Window function (without much luck..) to net the following result.

where 1 is today and 0 is yesterday.

What can I try next? I’m unsure what to search for.

Advertisement

Answer

Assuming the dates are continuous, we don’t even need analytic functions but instead we can just use DATEDIFF:

Demo

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement