Page 1 of 1

Can value returned by Current time function be 24:00:00?

PostPosted: Wed Feb 20, 2013 10:14 pm
by letmelive
Hi,
What will be the value of WS-CURR-TIME if the statement below is executed at 24.00? Will it have 24:00:00 or 00:00:00 or 00:00:01? Is there a way to test this on my own without waiting until 24.00?

EXEC SQL
SET :WS-CURR-TIME = CURRENT TIME
END-EXEC.

Version of DB2 being used is DB2V9.1.

Thanks,
LML

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Wed Feb 20, 2013 10:23 pm
by Akatsukami
Perhaps in this case rather than running a test, reading the fine manual on time values would be a preferable way to start.

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Fri Feb 22, 2013 11:39 am
by dick scherrer
Hello,

What will be the value of WS-CURR-TIME if the statement below is executed at 24.00?
This cannot happen . . .

The hours of a day are 00 thru 23,

As suggested, investing some research time in the documentation would be good.

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Tue Feb 26, 2013 2:20 pm
by GuyC
since we are on the subject : DB2 will accept '24.00.00' as a valid time which could be useful for some queries :
select current_time
      + (23 - hour(current_time)) hours
      + (59 - minute(current_time)) minutes
      + (60 - second(current_time)) seconds
      ,current_time
      - hour(current_time) hours
      - minute(current_time) minutes
      - second(current_time) seconds
      ,timestamp(current_date,'24.00.00')
from sysibm.sysdummy1

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Tue Feb 26, 2013 8:50 pm
by Ed Goodman
This cannot happen . . .

The hours of a day are 00 thru 23,

As suggested, investing some research time in the documentation would be good.


But the book actually says the numbers for hours can be 00 through 24. If the hour is 24, then the minutes and seconds will be zeroes.

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Wed Feb 27, 2013 4:49 am
by dick scherrer
Hello,

Does this mean that "old" code might have some slight difference(s) than new code that uses hr 24 in db2?

Re: Can value returned by Current time function be 24:00:00?

PostPosted: Wed Feb 27, 2013 3:55 pm
by Akatsukami
I think everyone's correct here:
  • Getting the system time through, e.g., CURRENT TIME, will never produce a value of 24:00:00.
  • Nonetheless, a time value of 24:00:00 is recognized as valid by DB2, and can be used for special purposes as per GuyC.
  • Hi Opal!

Opal'd