简体   繁体   中英

Time field e.g. "14:24:05" - show only "14:24" without seconds

I have a time field in db2 named "chgtime" in library "flow", table "changes"

How can I convert this time field, that it only shows me the hour and minute like "14:25" or with text only the hour like "the hour was 14".

For example, if time in one row is eg "14:24:05" the output in query should be like "14:25".

For following statement I get only null for all values in chgtime

select varchar_format(varchar(chgtime), 'hh24') as hour_minute from flow.changes

Thank you!

Try this:

select VARCHAR_FORMAT (TIMESTAMP (CURRENT DATE) + MIDNIGHT_SECONDS (chgtime) SECONDS, 'HH24:MI')
from flow.changes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM