CFLib.org – Common Function Library Project

DifferentDay(date1, date2)

Last updated March 21, 2002
Download UDF

author

Matthew Walker                                    Matthew Walker

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

 
Rated 0 time(s). Average Rating: 0

Description:
Check if two dates refer to the same day. This is different from using the built-in function DateDiff("d") as it will only count whole days difference, whereas a difference of just a second could be the difference between one day and another.

Return Values:
Returns a boolean.

Example:

<cfoutput>
DifferentDay test:
#DifferentDay("{ts '2003-01-01 23:59:59'}","{ts '2003-01-02 00:00:00'}")#<br>
Compare to DateDiff:
#DateDiff("d","{ts '2003-01-01 23:59:59'}","{ts '2003-01-02 00:00:00'}")#
</cfoutput>

Parameters:

Name Description Required
date1 First date to check. Yes
date2 Second date to check. Yes

Full UDF Source:

<cfscript>
/**
* Check if two dates refer to the same day.
*
* @param date1      First date to check.
* @param date2      Second date to check.
* @return Returns a boolean.
* @author Matthew Walker (matthew@cabbagetree.co.nz)
* @version 1, March 21, 2002
*/

function DifferentDay(date1, date2) {
    return ( ( DayOfYear(date1) NEQ DayOfYear(date2) ) OR ( Year(date1) NEQ Year(date2) ) );
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson