• 1 reply
  • Latest Post - ‏2013-12-04T10:00:10Z by JJ@IBM
1 Post

Pinned topic Subtracting hours returns negative number

‏2013-12-02T19:20:28Z |


I have a field called StartDate defined as DateTime.
I need to just get the hour of the StartDate field and then subtract 5 hours from that.
I can use this statement, but anything from midnight to 4am returns a negative number:
   SELECT StartDate, (TO_CHAR(StartDate, '%H') -5) As Hours FROM calls

I think I need to do the subtraction before the TO_CHAR statement pulls just the Hours, but I can't get that syntax worked out.
I have much more experience with SQL Server and am trying to get more involved with Informix.

Sorry if this is basic but I have been looking through the doc and Googling for along time now.

Any ideas?