COUNT_DAYS function

The Klipfolio COUNT_DAYS function returns the number of whole days between two dates. You can also exclude a day of the week or a holiday from the results.

Syntax

COUNT_DAYS( start , end , exclude DOW , holidays )

Parameters

start The start date to begin counting. Unix time format vector
end The end date to stop counting. Unix time format vector
exclude DOW optional: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday Unix time format vector
holidays

optional: for example, DATE( 25-12-2013, dd-MM-yyyy).

If the holidays parameter is specified, the exclude DOW parameter must also be specified.

When days are not excluded, use ARRAY to specify the excluded DOW parameter.

Unix time format vector

Examples

  A B
1 2013-01-21 2013-01-31

 

The following examples are based on the above text:

COUNT_DAYS( DATE( A:A , "yyyy-MM-dd") , DATE( B:B , "yyyy-MM-dd")) 

Returns: 11

COUNT_DAYS( DATE( B:B, "yyyy-MM-dd" ) , DATE( A:A , "yyyy-MM-dd" ) ) 

Returns: -11

 

The following example excludes Sundays and Saturdays, as well as 07-01-2014 and 07-02-2014.

COUNT_DAYS( DATE( 06-01-2014, "MM-dd-yyyy" ) , DATE( 07-31-2014 , "MM-dd-yyyy" ) , ARRAY( "Sun", "Sat" ) , ARRAY( DATE( 07-01-2014 , "MM-dd-yyyy" ) , DATE( 07-02-2014 , "MM-dd-yyyy" ) ) )

Returns: 42

 

The following example specifically excludes 07-01-2014 and 07-02-2014.

COUNT_DAYS( DATE( 06-01-2014, "MM-dd-yyyy" ) , DATE( 07-31-2014 , "MM-dd-yyyy" ) , ARRAY( ), ARRAY( DATE( 07-01-2014 , "MM-dd-yyyy" ) , DATE( 07-02-2014 , "MM-dd-yyyy" ) ) )

Returns: 59

 

The following example excludes December 25th of the current year. 

COUNT_DAYS( DATE_STARTOF( TODAY(), year ) , DATE_ENDOF( TODAY() , year ) , ARRAY( ), DATE( CONCAT( 12-25-, DATEVALUE( TODAY(), "yyyy"), "MM-dd-yyyy" ) ) )

Returns: 364

Related links:

Date and time functions