Skip to main content
May 2, 2007
Answered

"2:00 am" is an invalid date or time string.

  • May 2, 2007
  • 3 replies
  • 305 views
Hello.

I'm trying to (parsed down to this for easy reading):
<cfquery name="rsInsertEventInfo" datasource="#application.dsn#">
INSERT INTO et_events
(
event_start_time
)
VALUES
(
...
)
</cfquery>

For "..." above, I've tried:
<cfqueryparam cfsqltype="CF_SQL_TIME" value="#timeformat(attributes.txt_event_start_time, "hh:mm:ss")#">
and
<cfqueryparam cfsqltype="CF_SQL_TIME" value="#attributes.txt_event_start_time#">

But I keep getting:
"2:00 am" is an invalid date or time string (assuming I select 2:00 am from the js timepicker)

Do I need to switch to using a TIMESTAMP column type (instead of TIME)? Or is there a way to make this work?

Thank you for suggestions!
    This topic has been closed for replies.
    Correct answer
    Thank you! Both of these posts have helped me to track down the problem. For now I will probably just not use cfqueryparam for the time field. I meant to mention, it is a MySQL db.

    Thanks again.

    3 replies

    Correct answer
    May 2, 2007
    Thank you! Both of these posts have helped me to track down the problem. For now I will probably just not use cfqueryparam for the time field. I meant to mention, it is a MySQL db.

    Thanks again.
    Inspiring
    May 2, 2007
    I am not sure which type of database you are dealing with but in my experience with MySQL you have to use a 24-hour clock when posting times.

    I have always used #LSTimeFormat(Var, "H:mm:ss")#

    (You might have to put that in quotes... not sure at the present time...)

    The capital H is for 24 hour... while the lowercase h is for 12 hour...
    Inspiring
    May 2, 2007
    To troubleshoot try the following.
    1. Take away the cfqueryparam tag. if it still fails,
    2. Hard code "02:00:00", if it still fails
    3. try your db's equivalent of time(current_timestamp)