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

Datecompare compares date AND time - how to compare just date?

I am using datecompare in this manner:

#DateCompare(now(),getDD.DueDate)#

However, I am not getting the results I'm looking for because the date AND time of now() of being compared to just a date and zero hours.  I just want to compare date for date.  How can I fix this?
0
David Williamson
Asked:
David Williamson
2 Solutions
 
danrosenthalCommented:
try this...

<CFSET datetimestart = "8/08/04 8:15pm">
<CFSET datetimeend = "8/10/04 1:30am">

<CFOUTPUT>
#datediff('d',datetimestart,datetimeend)# days
#evaluate(datediff('h',datetimestart,datetimeend) MOD 24)# hours
#evaluate(datediff('n',datetimestart,datetimeend) MOD 60)# minutes
</cfoutput>
0
 
tim_csCommented:
Try this #DateCompare(DateFormat(now(), 'MM/DD/YYYY'), getDD.DueDate)#
0
 
mrichmonCommented:
If you just want the effects of datecompare with date only then use tim_cs's solution.

If you want to be able to fine-control the comparison use datediff.

Here is a page that explains the first parameter to datediff for the different comparisons

http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/functions-pt158.htm
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
David WilliamsonIT DirectorAuthor Commented:
This seems to do exactly what I'm looking for:

#DateCompare(CreateDate(year(now()),month(now()),day(now())), getFU.FUDueDate)#
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hello theamzngq!

You can also do it in this manner :

<cfset Date1 = DateFormat(now(),'yyyy/mm/dd')>
<cfset Date2 = DateFormat(getDD.DueDate,'yyyy/mm/dd')>

#DateCompare(Date1,Date2)#

Regards!
eNTRANCE2002 :-)

0
 
David WilliamsonIT DirectorAuthor Commented:
I tried this

#DateCompare(DateFormat(now(), 'MM/DD/YYYY'), getDD.DueDate)#

which is essentially what you have written, only broken up into variables, and it didn't work, which is why I went with the above.
0
 
tim_csCommented:
What results did my example give you?  I tested it and it worked fine for me.
0
 
David WilliamsonIT DirectorAuthor Commented:
sorry for the delay, folks.  haven't been at work for a bit...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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