In my Redshift table I have 2 columns that stores timestamp values: start_date_time and end_date_time.
I need to find the difference between start_date_time and end_date_time, such that, if difference is 1 day, then result should be 1. If diff is 12 hours, than result should be 0.5, if diff is 8 hours - than 0.3333 etc.
How can I do this? I tried to use datediff function: but that will not return what I wanted:
select datediff(day,'2011-12-31 8:30:00','2011-12-31 20:30:00') as day_diff; Will result in 0. But I need 0.5, because difference is 12 hours.