A co-worker just walked in and asked how to subtract timestamps in SQL. Easy, you just use the TIMESTAMPDIFF() function. Now, personally I just plain hate this function because it has some serious shortfalls: It approximates the difference between timestamps assuming 365 day years and 30 day months It takes some really odd arguments. So, I think there is a need for an exact and generic function which subtracts dates or timestamps. There are two ingredients which DB2 supplies natively which come in handy: JULIAN_DAY() Given a DATE or TIMESTAMP...

[More]
Marcações:
timestampdiff
arithmetic
julian_day
datetime
extract
interval