Coldfusion trouble with dates!

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


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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'

clivecrawdevilAuthor Commented:
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 ...
clivecrawdevilAuthor Commented:
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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.