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)
2 Likes

I had a similar problem but realized you could simply change the date field’s format to HH:mm. This extracts the time portion of the datetime field without a calculation. If you want to put both the date and time portions in the same visual but in two dimensions, you can create a dup field under a different name and set format separately.