• 0

# Formula based on Leave days

## Question

Hello,

I have two fields, Start Date and End Date. I want to create a Formula field that will calculate the number of days between the two dates. Can you help?

## Recommended Posts

• 0
Just now, taylorswiftlover said:

Hello,

I have two fields, Start Date and End Date. I want to create a Formula field that will calculate the number of days between the two dates. Can you help?

Hello @taylorswiftlover,

You can use the DateDiff function. Follow the formula here: DateDiff(Day, [@field:Start_Date], [@field:End_Date])

##### Share on other sites

• 0

Here is a reference that you can use for different math functions available in Caspio: https://howto.caspio.com/function-reference/.

##### Share on other sites

• 0

Thanks. But I forgot to mention, I only wanted to calculate where all the leave type is set to 'Vacation'. If the value is something else, I can just place a zero or null or something. Will that work?

##### Share on other sites

• 0
Just now, taylorswiftlover said:

Thanks. But I forgot to mention, I only wanted to calculate where all the leave type is set to 'Vacation'. If the value is something else, I can just place a zero or null or something. Will that work?

Sure! Just make sure that you have another field for the leave type with text datatype and you can create the formula similar to this:

CASE WHEN [@field:Leave_Type] = 'Vacation' THEN DateDiff(Day, [@field:Start_Date], [@field:End_Date]) ELSE 0 END

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.