I’m reading an integer field (store open time) that’s in seconds of a day, and converting it to something someone would actually be able to read.
Example:
32400 seconds = 9 AM (32400/3600 = 9)
This is fine if every store opens exactly on the hour, but now some stores open and close at the half hour.
Example
9:30 comes back as 9 (34200/3600 = 9), which is not good. I don’t want 34200 to come back as 9.5 either.
Ideally I want 32400 to come back as 900 and 34200 to come back as 930, and 46800 to come back as 1300. Both the input and output parameters need to be integers (I can’t change column types).
Any easy way to do this in DB2? Thanks
This is very simple (provided you’re using DB2 on Linux, UNIX or Windows):
This will return the desired integer
930for an input of 34200, and1300for an input of 46800.