CFLib.org – Common Function Library Project

GetDB2TimeStamp(dateObj, emulateTick)

Last updated June 27, 2002

author

Chris Wigginton

Version: 1 | Requires: CF5 | Library: DatabaseLib

Description:
Takes a ColdFusion date object and returns a DB2 formatted timestamp. A second parameter "emulateTick" determines if tick count emulation is added to the date object.

Return Values:
Returns a string.

Example:

<cfoutput>
#GetDB2TimeStamp(Now(), "Yes")#<BR>
#GetDB2TimeStamp(Now(), "No")#
</cfoutput>

Parameters:

Name Description Required
dateObj A data object. Yes
emulateTick A boolean. Yes

Full UDF Source:

/**
 * Takes a ColdFusion date object and returns a DB2 formatted timestamp.
 * 
 * @param dateObj 	 A data object. (Required)
 * @param emulateTick 	 A boolean. (Required)
 * @return Returns a string. 
 * @author Chris Wigginton (cwigginton@macromedia.com) 
 * @version 1, June 27, 2002 
 */
function getDB2TimeStamp(dateObj, emulateTick)
{
	var tick = "000000";
	// We can partially emulate milliseconds by 
	//grabbing the current tick and applying it to the date object
	if(emulateTick IS "Yes")
		tick = Right(GetTickCount(),3) & "000";
		
	return DateFormat(dateObj, "yyyy-mm-dd-") & TimeFormat(dateObj, "HH.mm.ss.") & tick; 
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson