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



IBM's flagship relational database management system

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

Postby letmelive » Wed Feb 20, 2013 10:14 pm

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
letmelive
 
Posts: 20
Joined: Thu Oct 04, 2012 1:27 am
Has thanked: 6 times
Been thanked: 0 time

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

Postby Akatsukami » Wed Feb 20, 2013 10:23 pm

Perhaps in this case rather than running a test, reading the fine manual on time values would be a preferable way to start.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

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

Postby dick scherrer » Fri Feb 22, 2013 11:39 am

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.
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
letmelive (Sat Apr 27, 2013 1:53 am)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

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

Postby GuyC » Tue Feb 26, 2013 2:20 pm

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
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

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

Postby Ed Goodman » Tue Feb 26, 2013 8:50 pm

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.
Ed Goodman
 
Posts: 341
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times

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

Postby dick scherrer » Wed Feb 27, 2013 4:49 am

Hello,

Does this mean that "old" code might have some slight difference(s) than new code that uses hr 24 in db2?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

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

Postby Akatsukami » Wed Feb 27, 2013 3:55 pm

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
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

These users thanked the author Akatsukami for the post:
letmelive (Sat Apr 27, 2013 1:53 am)
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post