Skip to main content

Hi,


How can I change time format 8:00 into 0800?


Thanks

Erwin

Hi Erwin,


I am not sure what you mean by a “time format 8:00”.

What field type are you using ?


If you are using a DateTime field with Time enabled; then you can use the DATETIME_FORMAT(Mdate], ']specified output format]') function in a formula field to get the desired output.


Is that what you are looking for ?


Florian VERDONCK


Hi Erwin,


I am not sure what you mean by a “time format 8:00”.

What field type are you using ?


If you are using a DateTime field with Time enabled; then you can use the DATETIME_FORMAT(Mdate], ']specified output format]') function in a formula field to get the desired output.


Is that what you are looking for ?


Florian VERDONCK


Hi, thanks!


It’s a Duration field and Time has to be formatted in ‘0hmm’, without colon. For example:


8:00 -> 0800

4:15 -> 0415

6:02 -> 0602

etc


Erwin


Hi, thanks!


It’s a Duration field and Time has to be formatted in ‘0hmm’, without colon. For example:


8:00 -> 0800

4:15 -> 0415

6:02 -> 0602

etc


Erwin


Hi again @Erwin_Van_den_Bogaer,


Ok I understand. In Airtable, Duration is not the “Time” part of a DateTime, it is really just a “Duration”.

To do what you are asking for, you have to set an intermediate field that will calculate the corresponding DateTime.




  1. Create a new Formula field formatted as DateTime

    DATEADD(TODAY(), Duration, 'seconds')

    This will create a “today” date with time = 00:00 then add the Duration to it




  2. Convert this DateTime to a String

    DATETIME_FORMAT(DateTime, "hhmm")




This result can actually be achieved using a one line formula :

DATETIME_FORMAT(DATEADD(TODAY(), Duration, 'seconds'), "hhmm")



Please tell me if this fit your needs.

If it does work on your side, please mark this reply as an answer 🙂


Florian VERDONCK


Reply