Skip to main content
Known Participant
November 24, 2009
Question

invalid date format Help

  • November 24, 2009
  • 4 replies
  • 1289 views

Good day everyone, I am making a Spanish version of a site where on the first line I am declaring the locale as:

<cfset locale = SetLocale("Spanish (Standard)")>

I am then doing a query to my database where I get a date which I am trying to show like this:

#LSDateFormat(st.INICIO, "mmm/dd/yyyy", locale)#

Where INICIO is the date value from the query named st of the database.

I am getting an error with the following:

08/16/09 is an  invalid date format.

ANy help will be appreciated.

Sincerely,

A not so happy coder today!!!

    This topic has been closed for replies.

    4 replies

    pixculimAuthor
    Known Participant
    November 25, 2009

    Thank you guys, you are correct there was no need for the fsetLocale(), and the problem was on the server config swaping the day and month positions, which was giving the incorrect parameters to the LSDateFormat Function.

    ALl I had to do before I called the LSDateFormat() Function was to preformat the dates that the DB sends to the correct format.

    Something like this

    #LSDateFormat((dateFormat(st.INICIO, "dd/mm/yyyy")),"dd/mmm/yyyy")#

    Sincerely,

    A happy coder Now....

    November 25, 2009

    I got such problems because the DB return datetime format not supported, a mix between the SQL serveur date time format, modifyed by windows local settings as a result, it swap the mounth and the day, that causes errors when the day was higher than 12. That may be a clue.

    Inspiring
    November 25, 2009

    first off if you're setting the locale via setLocale(), there's no need to pass in the locale for your LS functions especially because what setLocale *returns* is the *old* locale not the one you just set. get it?

    Inspiring
    November 25, 2009

    What is the datatype of the field in the db?

    pixculimAuthor
    Known Participant
    November 25, 2009
    • Microsoft SQL database
    • datetime - data type
    • condensed Data Type = datetime
    • Full-text specification = no
    • Identety Specification = no