Search code examples
datetimecoldfusioncfquery

Date Display problem in ColdFusion


When I retrived a Date field in TOAD it displayed like is '1/18/2038 9:14:07 PM',

But when I rertrived in Coldfusion using cfquery and displayed using , then I got the date on screen like '2038-01-18 21:14:07.0'.

Does anyone have idea why it displayed in different format? Is there anyway we can make it display like TOAD format?

I am using Oracle 10g DB and coldfusion 8


Solution

  • You could 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 could use

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

    to have datetime format

    Happy coding