# How to get the difference of minutes of two fields?

Topic Labels: Formulas
1469 7
cancel
Showing results for
Did you mean:
6 - Interface Innovator

There are 2 fields of type “Data”.

What formula should be written for field 3 so that the difference in minutes between the fields ‘Date1’ and ‘Date2’ is calculated there?

7 Replies 7
18 - Pluto

`IF(`
`AND(date2,date1),`
`DATETIME_DIFF(date2, date1, 'minutes')`
`)`

6 - Interface Innovator

No.

18 - Pluto

Looks like you’ve got your date fields setup incorrectly. You’ll need to go into your customization options for your date fields, and make sure they’re both set to either GMT or not. They both need to be set to the exact same option. You can’t have one field set to GMT and the other field set to NON-GMT, because then you’re telling Airtable that your fields are in 2 different time zones.

6 - Interface Innovator

They are the same

18 - Pluto

I wasn’t looking too carefully at the actual dates you typed in, but the formula that I gave you is giving you the exact number of minutes that have elapsed between Date 1 and Date 2. Are you saying that you want it to completely ignore the dates altogether and just look at the times?

6 - Interface Innovator

Yes. I just need time. The day of the month and year can be left alone

18 - Pluto

If you’re ignoring the dates, then I would probably do it like this.

This formula will extract the time from the date fields as 24-hour military time, and then the math can be done on those military times:

``````IF(

AND(Date2,Date1),

DATETIME_DIFF(
DATETIME_PARSE(TIMESTR(Date2),'HH:mm'),
DATETIME_PARSE(TIMESTR(Date1),'HH:mm'),
'minutes'
)

)``````