I didn't realise you could wrap CF fundctions "DateFormat" around data from a query ie dbDate.
Are you sure you can do this.
Main Topics
Browse All TopicsHow to you do a date comparison to a datetime.
ie: Have a datetime in a database and want to get all records for a single date.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Yah! Of course, I'm really... really... sure 'coz I have already tried using it. In fact, I have been implementing this to one of my projects which is "Web Account System".
By the way, you can actually remove the symbols "#" in between the CF DateFormat function.
So, it would be :
Where DateFormat(dbDate,'yyyy-mm
Haven't you tried this before ???
Regards!
eNTRANCE2002 :-)
By the way Plucka, I mistakenly give you the information.
Actually, you should remove the symbols "#" coz it will be expected to encounter an error. The DateFormat function that we are using here is not the CF DateFormat function but it's the SQL DateFormat function.
This is the syntax :
DATEFORMAT ( datetime-expression, string-expression )
In which the string expression is just like the same as the "mask" that we are setting on the CF DateFormat function.
Hope this makes clear to you.
Best regards!
eNTRANCE2002 :-)
By the way Plucka, I just want to have a clarification.
Are you going to get only those records which has StartDateTime value within the range from "YYYY-MM-DD 00:00" to "YYYY-MM-DD 23:59"???
How about if the StartDateTime value is beyond that range but the same date?
Like for example :
'YYYY-MM-DD 23:59:00.1'
'YYYY-MM-DD 23:59:01'
It will not be returned... Test it for confirmation.
It is much better if you do your condition like this :
AND StartDateTime = '#DateFormat(frmWorkDate, "YYYY-MM-DD")#'
Since you want to get all records for a single date as what you have specified on your main post(QUESTION).
Best wishes!
eNTRANCE2002 :-)
which database are u using...
if its oracle use to_char() function
<CFQUERY name="qGetRecord" datasource="DSN">
Select * From TableName
Where To_Char(dbDate,'dd/mm/yyyy
</CFQUERY>
if its MS SQL u have convert()
http://www.sqlteam.com/ite
Regards
Hart
I think what you want to use is a SQL function convert.
You can format the database datetime field and compare at the same time.
<cfquery name="mystuff">
select * from table
where convert(varchar(12),databa
</cfquery>
101 is the formating used for the date time conversion which equals : "mm/dd/yyyy"
You can find this info in SQL books online under: "Convert and Cast"
wolffy
Business Accounts
Answer for Membership
by: entrance2002Posted on 2004-11-17 at 22:29:51ID: 12611991
Hello Plucka!
m-dd')# = <cfqueryparam cfsqltype="cf_sql_date" value="#yourDate#">
You can do something like this :
<CFQUERY name="qGetRecord" datasource="DSN">
Select * From TableName
Where #DateFormat(dbDate,'yyyy-m
</CFQUERY>
Hope this helps you. Just try it.
Goodluck!
eNTRANCE2002 :-)