Subtracting two dates, returning hour error

I am new to Toad DP so please bear with me. I am trying to subtract two dates and return the hour difference. I have used the DATEDIFF function but whenever I set the dateunit to hh, I receive and error that says hh is not valid in the context that it is used. Thanks!

Always good to give as much detail about what you're trying to do... for instance, on which platform and version of the database, etc. which version of TDP, etc.

That said, working with dates can be tricky and each platform seems to treat dates (and date functions) differently. You should be able to use functions like DATEDIFF... here's an example where I created a calculated column using DATEDIFF() on an Oracle table set... there are almost assuredly other ways to do this... hope this helps.

1 Like

The syntax varies slightly by SQL flavor. For example, postgres uses "hh" for hour whereas MySQL's datediff doesn't support granularity specification and oracle only supports days (DD) and seconds (SS).