Skip to main content
Known Participant
March 29, 2011
Answered

How to use the exact time

  • March 29, 2011
  • 1 reply
  • 763 views

I know there is a function called CreateODBCDateTime and CreateODBCDatebut I don't know how to use CreateODBCDateTime. I know how to use CreateODBCDate:

<cfset Date=CreateODBCDate(Now())><cfset Date=dateFormat(Date,"mmm dd yyyy")> And the date will output like Mar 29 2011. How would i achevie something like 3:28pm Mar 29 2011?

    This topic has been closed for replies.
    Correct answer ilssac

    The CreateODBC...() functions are for formating dateTime objects in a format used by ODBC database connections.  Those are NOT used very much any more.  ColdFusion uses JDBC database connections for most database management systems.

    The CreateODBC...() functions are NOT designed to do anything about creating human readable date|time strings.  If you want to format the date part of a datetime object in a nice human readable format use the dateFormat() function.  If you want to format the time part of a datetime object in a nice human readable format use the timeFormat() function.

    If you want both, use both functions.

    <cfset DATE = timeFormat(now(),'h:mmtt') & ' ' & dateFormat(now(),'mmm dd yyy")>

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    March 29, 2011

    The CreateODBC...() functions are for formating dateTime objects in a format used by ODBC database connections.  Those are NOT used very much any more.  ColdFusion uses JDBC database connections for most database management systems.

    The CreateODBC...() functions are NOT designed to do anything about creating human readable date|time strings.  If you want to format the date part of a datetime object in a nice human readable format use the dateFormat() function.  If you want to format the time part of a datetime object in a nice human readable format use the timeFormat() function.

    If you want both, use both functions.

    <cfset DATE = timeFormat(now(),'h:mmtt') & ' ' & dateFormat(now(),'mmm dd yyy")>