Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6498 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I would like to define a new field, that would subtract two different times, and give me the difference.

I have field A, the arrival time, and field B, the departure time. I want to have C show how many hours are in between them.

All my events last less than a day.

The problem I'm having is that Field A and Field B, are in Time format. Field C, is a calculation that has (Field :( - (Field A). What I want is for field C to give me the difference, but what it's doing is it's giving me a negative number because it's going back a whole day from AM to PM.

Can anyone give me a tip on what to change?

Thanks.

Posted

Time doesn't seem to want to subtract directly...

(GetAsNumber(arrivalTime) - GetAsNumber(departureTime)) / 3600

Or just

GetAsNumber(arrivalTime - departureTime) / 3600

Posted

Time doesn't seem to want to subtract directly...

Since when? A simple Arrival - Departure works fine for me.

I suspect the problem is with events crossing midnight, which can be handled by:

Arrival - Departure + 86400 * ( Departure > Arrival )

You can leave the result as Time, and format the display to your liking, or - if you want decimal hours - make it a Number and divide by 3600.

Posted

Don't know, didn't seem to work for me... kept giving me much larger neg values

i.e. 1pm - 11am = -22 (i don't remember if that's actually what it spat out, but it was much larger than it should have been).

Don't know, seems to work now, and you're probably right re the midnight thing -- but why does it make the assumption?

Posted

Since when? A simple Arrival - Departure works fine for me.

I suspect the problem is with events crossing midnight, which can be handled by:

Arrival - Departure + 86400 * ( Departure > Arrival )

You can leave the result as Time, and format the display to your liking, or - if you want decimal hours - make it a Number and divide by 3600.

That is exactly the problem I'm having. For events crossing midnight, it's counting backwards, or adding 12 to it and giving me a negative result. I tried your method and it still seems to be doing that.

Posted

It works perfectly for me.

Departure 1:00 PM (or even 1 PM)

Arrival 11:00 AM (or even 11 AM)

Calculation (result is time) = Arrival - Departure + 86400 * ( Departure > Arrival )

Result: 22 hours or 22:00:00

Nothing I do can make it run negative or break. Are you sure all three fields are time? And are you sure you don't have Arrival and Departure reversed? That's what it sounds like you're doing. But even so, Comment's calculation would not break.

This topic is 6498 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.