CFLib.org – Common Function Library Project

getBegOfDayTS(date)

Last updated January 30, 2006

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

 
Rated 0 time(s). Average Rating: 0

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:

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

Parameters:

Name Description Required
date Date to use. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * 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;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson