CFLib.org – Common Function Library Project

getEndOfDayTS(date)

Last updated January 30, 2006

author

Sami Hoda

Version: 1 | Requires: CF5 | Library: DateLib

Description:
A function which returns a End Of Day TimeStamp. For example, 1/1/2000 returns {ts '2000-01-01 23:59:59'}. Useful for SQL queries when users search by date ranges and you need to include all values by the end of a certain date period.

Return Values:
Returns a timestamp.

Example:

<cfset EOD = getEndOfDayTS("1/1/2000")>
<cfoutput>#EOD#</cfoutput>

Parameters:

Name Description Required
date Date to use. Yes

Full UDF Source:

/**
 * A function which returns a End Of Day TimeStamp. For example, 1/1/2000 returns {ts '2000-01-01 23:59:59'}.
 * 
 * @param date      Date to use. (Required)
 * @return Returns a timestamp. 
 * @author Sami Hoda (samihoda@gmail.com) 
 * @version 1, January 30, 2006 
 */
function getEndOfDayTS(date) {
    var vDate = date;
    vDate = dateFormat(vDate, 'MM/DD/YYYY');
    vDate = DateAdd("h",23,vDate);
    vDate = DateAdd("n",59,vDate);
    vDate = DateAdd("s",59,vDate);
    
    return vDate;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson