Extract Time From Date

Hi,

I want to extract the hour and minute part from a date which is in 24hr format. I have created a calculated field like below,
ifelse(isNull(DEPARTTIME), ‘’, concat(toString(extract(‘HH’,DEPARTTIME)),’:’, toString(extract(‘MI’,DEPARTTIME))))

The calculated field works in most cases. However, if there is a time like 08:05 in the date field the calculated field returns 8:5 instead of 8:05.
If it’s 08:15, the calculated field will correctly return 8:15. There is some problem with the “zeros” coming in time part.

Any help will be highly appreciated

how about doing this instead?

substring(formatDate(DEPARRTTIME), 12, 5)
1 Like