Truncate Time in a Date

I have this data.

11/17/2021 6:00 AM

I want to truncate the time 6:00 AM from the date. How will I do it in Coda ?

the date and time is stored as a floating point number.
the integer part is the date.
the decimal fraction part is the time.

so round or truncate to an integer will leave the date without the time

1 Like

As @Xyzor_Max said, Dates, Times and Datetimes are stored as numbers within Coda and depending on your use case scenario, where your datetime is currently stored and what is the finality of the extraction there might be different ways to do this :blush:

The formula ToDate() could potentially help you here :blush:

Here’s a very quick sample using ToDate() in very few somewhat different ways :blush: .

2 Likes

The best way is to either use

  • ToDate(), or
  • DateTimeTruncate("day")

The first one does what you need: strips the time and converts to a date. There’s a sister function ToTime() that strips the date and leaves the time.

The second one strips everything to the specified accuracy. It could be “year”, “month”, “week” etc as well as “minute”, “hour”, not just a day.

P.S. I see as I briefly left AFK, @Pch already answered this :slight_smile: I’ll leave my reply for the DateTimeTruncate() option though. You may find it useful to e.g. quickly convert a date to the Fiscal Month in your budget doc or whatnot :slight_smile:

3 Likes

Ah! I always forget about that one :point_up: … My mental notes need some updates :sweat_smile:

Thanks for the reminder @Paul_Danyliuk :raised_hands: !

2 Likes