Problem with displaying dates in ColdFusion

When I extracted the Date field in TOAD, it displayed as " 1/18/2038 9:14:07 PM",

But when I moved to Coldfusion using cfquery and displayed usage, then I got the date on the screen, for example. ' 2038-01-18 21:14:07.0'

Does anyone have an idea why it is displayed in a different format? In any case, can we display it as a TOAD format?

I am using Oracle 10g DB and coldfusion 8

+5
source share
2 answers

You can use something like:

<cfquery datasource="northwind" name="queryDB">
  SELECT date_used, time_used
  FROM invoicesTable
</cfquery>

<cfoutput query="queryDB">
#DateFormat(date_used, "m/d/yyyy")#
#TimeFormat(time_used, "h:mm tt")#
</cfoutput>

I think this is what you want.

you can use

#DateTimeFormat(Now(), "mmm d, yyyy","h:mm TT")#

have a date and time format

Happy coding

+8
source

Coldfusion datetime, , , . Coldfusion , .

<!--- Assuming that 'myDateTime' is a datetime variable retrieved from cfquery --->
<cfoutput>
    <!--- Outputs: 1/7/2010 --->
    #dateFormat(myDateTime, "m/d/yyyy")#
    <!--- or use a mask shortcut - only outputs two digit year: 1/7/10 --->
    #DateFormat(myDateTime, "short")#

    <!--- Outputs: 8:47:14 AM --->
    #timeFormat(myDateTime, "h:mm:ss tt")#
    <!--- or use the shortcut: --->
    #TimeFormat(myDateTime, "medium")#
</cfoutput>

TOAD, dateFormat() timeFormat().

<!--- Outputs: '1/7/2010 8:47:14 AM' --->
<cfset toadFormat = dateFormat(myDateTime, "m/d/yyyy") & " " & TimeFormat(myDateTime, "medium")>

, . , myDateTime , , .

DateFormat() TimeFormat() Adobe. " " Pete Freitag.

+5
source

All Articles