# Extract Time From Date

**URL:** <https://community.amazonquick.com/t/extract-time-from-date/2853>\
**Category:** Q&A\
**Tags:** calculations, quick-sight\
**Created:** [April 7, 2022, 7:09am UTC](https://community.amazonquick.com/t/extract-time-from-date/2853 "2022-04-07T07:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philip](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@Philip](https://community.amazonquick.com/u/Philip)\
**Post date:** [April 7, 2022, 7:09am UTC](https://community.amazonquick.com/t/extract-time-from-date/2853/1 "2022-04-07T07:09:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![darcoli](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@darcoli](https://community.amazonquick.com/u/darcoli)\
**Post date:** [April 7, 2022, 8:08am UTC](https://community.amazonquick.com/t/extract-time-from-date/2853/2 "2022-04-07T08:08:10Z")

</div>

how about doing this instead?

```auto
substring(formatDate(DEPARRTTIME), 12, 5)

```

---

<div class="post-metadata">

**Author:** ![no\_hair](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@no\_hair](https://community.amazonquick.com/u/no_hair)\
**Post date:** [September 10, 2024, 8:44pm UTC](https://community.amazonquick.com/t/extract-time-from-date/2853/3 "2024-09-10T20:44:24Z")

</div>

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.
