Basic SQL recipes for web data

Hi Yali,

These are amazing, and we use these regularly for inspiration on modelling our data!

I have a quick question, I ran a query similar to your Recency to determine time to purchase. However, I found that doing a subtraction of one date from the other, as in your query lead to inaccurate results. I however did this again using a DATEDIFF function instead lead to the correct results.

Is there any reason why subtracting dates (using the derived_tstamp) gives different results to DATEDIFF?

Thanks again.