Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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


  • 3
  • 2
1 Solution
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)

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now