CFLib.org – Common Function Library Project

GetDB2TimeStamp(dateObj, emulateTick)

Last updated June 27, 2002
Download UDF

author

Chris Wigginton                                   Chris Wigginton

Version: 1 | Requires: ColdFusion 5 | 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:

<cfscript>
/**
* 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;
}
</cfscript>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson