SQL HOUR scalar function in DB2 for i SQL |
HOUR
The HOUR function returns the hour part of a value.
Syntax
HOUR(expression)
The argument should be an expression that returns either time, timestamp, character string, graphic string, or numeric data type. The return value is large integer. Also, the result can be NULL if the argument value is null.
Example#1:
If the argument is a string.
SELECT HOUR('2024-03-16-15.10.40.456465') FROM sysibm.sysdummy1
HOUR 15
Example#2:
If the argument is a timestamp
SELECT HOUR(current timestamp) FROM sysibm.sysdummy1
Or
SELECT HOUR(current_timestamp) FROM sysibm.sysdummy1
HOUR 11
Example#3:
If the argument is a time
SELECT HOUR(current time) FROM sysibm.sysdummy1
Or
SELECT HOUR(current_time) FROM sysibm.sysdummy1
HOUR 11