We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Coldfusion trouble with dates!

Medium Priority
Last Modified: 2013-12-24
Hi Experts

Having endless trouble with dates in my coldfusion application. I am trying to use a cfinput type=” datefield” with a mask of “DD/MM/YYYY” to work with European dates.

The field passes the date in the correct format but when its entered into my database it is in the wrong format e.g. MM/DD/YYYY.

I have changed my input from a cfinsert into a cfquery insert into. This still does not solve the problem

<cfquery name="Insert" datasource="ILRData">
Insert into tblQual
(L03, Datesat, Qualification, Result, Mark, Certificate, Tutor, Project)
values (#L03#, #DateFormat(CreateODBCDate(Datesat), "DD/MM/YYYY")#, '#Form.Qualification#', '#Form.Result#', #Form.Mark#, '#Form.Certificate#', '#Form.Tutor#', '#Form.Project#')

After using the DateFormat and CreateODBCDate fields the query is only passing the time into the database.

Please help


Watch Question


Did you try using the suffix _eurodate for you date field validation?

Then also, if your database Datesat column is datetime - just let it insert how it wants and when you query the db for this date - then format it european or however you want.

But to insert date - just use
<CFQueryparam CFSqlType="CF_Sql_Date" value="#form.Datesat#">

If your db date field is a type of text then use 'single quotes around form.Datesat'


Hi dgrafx

I have already got eurodate as validation the problem appears to be on the action page when the data is inserted into the table.

The problem is I am using the date in a grid on a flash form. And it always displays them funny (This is a known problem). Would the best way be to format the date when I call it in the query to populate the grid?

Seems like an awfully tricky way of dealing with dates? What if I want to query the database directly, all the dates are in the wrong format? Is there another way to deal with European dates in coldfusion? I have an access database as the backend.



Read my above post again.
The eurodate suggestion was just a suggestion.
The answer lies in the remainder of the post.
Don't worry about what the date looks like in the database - this doesn't affect you.
Your only concern is being able to insert, update, & display - is that correct?

Hope this helps ...


Sorry dgrafx it is causing me problems not being able to format the dates correctly, I have to run queries directly on this database and having the dates incorrectly formatted in the database causes information to be inaccurate.

I have tried to find a solution but have not come across anything that works.

Your help is much appreciated.


I'm sorry about the difficulty and I did not know you are running queries on your db.
You may need to change the date fields format to like short date - I think - experiment.
Or how about (if that doesn't work) create different fields for each date part
Like day is on col - month another etc

Below is just a recap in case you no longer need to run queries on db.

On your form you have
cfinput type="datefield" with a mask of "DD/MM/YYYY"

On your form action page you do an insert
Insert Into table

Then when you are viewing this record you have a query that selects DateSat
Your output looks like this:
#DateFormat(DateSat,"dd/mm/yyyy")# #TimeFormat(DateSat,"h:mm t")# (if you want time which would need to be specified on your original form or will be 12:00 AM)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.