CFLib.org – Common Function Library Project

GetDB2TimeStamp(dateObj, emulateTick)

Last updated June 27, 2002

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

 
Rated 4 time(s). Average Rating: 4.0

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:

view plain print about
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

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

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson