Copy link to clipboard
Copied
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!!!
Copy link to clipboard
Copied
What is the datatype of the field in the db?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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....