CFLib.org – Common Function Library Project

getBegOfDayTS(date)

Last updated January 30, 2006

author

Sami Hoda

Version: 1 | Requires: CF5 | Library: DateLib

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

Return Values:
Returns a timestamp.

Example:

<cfset BOD = getBegOfDayTS("1/1/2000 10:30 PM")>
<cfoutput>#BOD#</cfoutput>

Parameters:

Name Description Required
date Date to use. Yes

Full UDF Source:

/**
 * A function which returns a Beginning Of Day TimeStamp. For example, 1/1/2000 10:30 PM returns {ts '2000-01-01 00:00:00'}.
 * 
 * @param date      Date to use. (Required)
 * @return Returns a timestamp. 
 * @author Sami Hoda (samihoda@gmail.com) 
 * @version 1, January 30, 2006 
 */
function getBegOfDayTS(date) {
    var vDate = date;    
    vDate = dateFormat(vDate, 'MM/DD/YYYY');
    vDate = DateAdd("h",00,vDate);
    vDate = DateAdd("n",00,vDate);
    vDate = DateAdd("s",00,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