No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Common Date Formulas
| Available in: All Editions |
Watch a Demo: How to Calculate the Number of Days a Case is Open
Finding the Day, Month, or Year from a Date
Use the functions DAY( date ), MONTH( date ), and YEAR( date ) to return their respective numerical values. Replace date with a value of type Date (e.g. TODAY()).
To use these functions with Date/Time values, first convert them to a date with the DATEVALUE() function. For example, DAY( DATEVALUE( date/time )).
Finding Out if a Year Is a Leap Year
1OR(
2 MOD( YEAR( date ), 400 ) = 0,
3 AND(
4 MOD( YEAR( date ), 4 ) = 0,
5 MOD( YEAR( date ), 100 ) != 0
6 )
7)Finding Which Quarter a Date Is In
For standard quarters, you can determine which quarter a date falls in using this formula. This formula returns the number of the quarter in which date falls (1–4) by dividing the current month by three (the number of months in each quarter) and taking the ceiling.
1CEILING( MONTH ( date ) / 3 )1CEILING( ( MONTH ( date ) - 1 ) / 3)1AND(
2 CEILING( MONTH( date ) / 3 ) = CEILING( MONTH( TODAY() ) / 3 ),
3 YEAR( date ) = YEAR( TODAY() )
4)Finding the Week of the Year a Date Is In
1IF(
2 CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7) > 52,
3 52,
4 CEILING( ( date - DATE( YEAR( date ), 1, 1) + 1) / 7)
5)Finding Whether Two Dates Are in the Same Month
1AND(
2 MONTH( date_1 ) == MONTH( date_2 ),
3 YEAR( date_1 ) == YEAR( date_2 )
4)Finding the Last Day of the Month
1IF(
2 MONTH( date ) = 12,
3 DATE( YEAR( date ), 12, 31 ),
4 DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1
5)Displaying the Month as a String Instead of a Number
1CASE(
2 MONTH( date ),
3 1, "January",
4 2, "February",
5 3, "March",
6 4, "April",
7 5, "May",
8 6, "June",
9 7, "July",
10 8, "August",
11 9, "September",
12 10, "October",
13 11, "November",
14 "December",
15)1CASE(
2 MONTH( date ),
3 1, $Label.Month_of_Year_1,
4 2, $Label.Month_of_Year_2,
5 3, $Label.Month_of_Year_3,
6 4, $Label.Month_of_Year_4,
7 5, $Label.Month_of_Year_5,
8 6, $Label.Month_of_Year_6,
9 7, $Label.Month_of_Year_7,
10 8, $Label.Month_of_Year_8,
11 9, $Label.Month_of_Year_9,
12 10, $Label.Month_of_Year_10,
13 11, $Label.Month_of_Year_11,
14 $Label.Month_of_Year_12
15)Finding and Displaying the Day of the Week From a Date
1CASE(
2 MOD( date - DATE( 1900, 1, 7 ), 7 ),
3 0, "Sunday",
4 1, "Monday",
5 2, "Tuesday",
6 3, "Wednesday",
7 4, "Thursday",
8 5, "Friday",
9 "Saturday"
10)1CASE(
2 MOD( date - DATE( 1900, 1, 8 ), 7 ),
3 0, "Monday",
4 1, "Tuesday",
5 2, "Wednesday",
6 3, "Thursday",
7 4, "Friday",
8 5, "Saturday",
9 "Sunday"
10)Like the formula for getting the name of the month, if your organization uses multiple languages, you can replace the names of the day of the week with a variable like $Label.Day_of_Week_1, etc.
Finding the Next Day of the Week After a Date
1date + ( day_of_week - MOD( date - DATE( 1900, 1, 7 ), 7 ) )
2+
3IF(
4 MOD( date - DATE( 1900, 1, 7 ), 7 ) >= day_of_week,
5 7,
6 0
7)Finding the Number of Days Between Two Dates
To find the number of days between two dates, date_1 and date_2, subtract the earlier date from the later date: date_1 — date_2
1TODAY() - 30 > dateFinding the Number of Business Days Between Two Dates
1(5 * ( FLOOR( ( date_1 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_1 - DATE( 1900, 1, 8), 7 ) ) )
2-
3(5 * ( FLOOR( ( date_2 - DATE( 1900, 1, 8) ) / 7 ) ) + MIN( 5, MOD( date_2 - DATE( 1900, 1, 8), 7 ) ) )Adding Days, Months, and Years to a Date
If you want to add a certain number of days to a date, add that number to the date directly. For example, to add five days to a date, the formula is date + 5.
1IF(
2 AND(
3 MONTH( date ) = 2,
4 DAY( date ) = 29,
5 NOT(
6 OR(
7 MOD( YEAR( date ), 400 ) = 0,
8 AND(
9 MOD( YEAR( date ), 4 ) = 0,
10 MOD( YEAR( date ), 100 ) != 0
11 )
12 )
13 )
14 ),
15 DATE( YEAR( date ) + num_years, 3, 1)
16 DATE( YEAR( date ) + num_years, MONTH( date ), DAY( date ) )
17)1date + ( ( 365 / 12 ) * Number_months )- Returns March 1 if the future month is a February and the day is greater than 28. This portion of the formula performs the same for both leap and non-leap years.
- Returns the first day of the next month if the future month is April, June, September, or November and the day is greater than 30.
- Otherwise, it returns the correct date in the future month.
1IF(
2 MOD( MONTH( date ) + 2, 12 ) = 2,
3 IF(
4 DAY( date ) > 28,
5 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ), 3, 1 ),
6 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ), 2, DAY( date ) )
7 ),
8 IF(
9 OR(
10 MOD( MONTH( date ) + 2, 12 ) = 4,
11 MOD( MONTH( date ) + 2, 12 ) = 6,
12 MOD( MONTH( date ) + 2, 12 ) = 9,
13 MOD( MONTH( date ) + 2, 12 ) = 11
14 ),
15 IF(
16 DAY( date ) > 30,
17 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ),
18 MOD( MONTH( date ) + 2, 12 ) + 1, 1 ),
19 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ),
20 MOD( MONTH( date ) + 2, 12), DAY( date ) )
21 ),
22 IF(
23 MOD( MONTH( date ) + 2, 12 ) = 0,
24 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ) - 1, 12, DAY( date ) ),
25 DATE( YEAR( date ) + FLOOR( ( MONTH( date ) + 2 ) / 12 ),
26 MOD( MONTH( date ) + 2, 12), DAY( date ) )
27 )
28 )
29)Adding Business Days to a Date
1CASE(
2 MOD( date - DATE( 1900, 1, 7 ), 7 ),
3 3, date + 2 + 3,
4 4, date + 2 + 3,
5 5, date + 2 + 3,
6 6, date + 1 + 3,
7 date + 3
8)Finding the Hour, Minute, or Second from a Date/Time
1VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) )1IF(
2 OR(
3 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0,
4 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12
5 ),
6 12,
7 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) )
8 -
9 IF(
10 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12,
11 0,
12 12
13 )
14)1VALUE( MID( TEXT( date/time - TZoffset ), 15, 2 ) )1VALUE( MID( TEXT( date/time - TZoffset ), 18, 2 ) )1IF(
2 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12,
3 "AM",
4 "PM"
5)1IF(
2 OR(
3 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 0,
4 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12
5 ),
6 "12",
7 TEXT( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) )
8 -
9 IF(
10 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12,
11 0,
12 12
13 )
14 )
15)
16& ":" &
17MID( TEXT( date/time - TZoffset ), 15, 2 )
18& ":" &
19MID( TEXT( date/time - TZoffset ), 18, 2 )
20& " " &
21IF(
22 VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12,
23 "AM",
24 "PM"
25)Finding the Elapsed Time Between Date/Times
To find the difference between two Date values, subtract one from the other like so: date_1 — date_2 to return the difference in days.
1IF(
2 Diff_c > 0 ,
3 TEXT( FLOOR( Diff_c ) ) & " days "
4 & TEXT( FLOOR( MOD( Diff_c * 24, 24 ) ) ) & " hours "
5 & TEXT( ROUND( MOD( Diff_c * 24 * 60, 60 ), 0 ) ) & " minutes",
6 ""
7)Finding the Number of Business Hours Between Two Date/Times
1ROUND( 8 * (
2 ( 5 * FLOOR( ( date/time_1 - DATE( 1900, 1, 8) ) / 7) +
3 MIN(5,
4 MOD( date/time_1 - DATE( 1900, 1, 8), 7) +
5 MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) )
6 )
7 )
8 -
9 ( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) +
10 MIN( 5,
11 MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) +
12 MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) )
13 )
14 )
15 ),
160 )