Solved

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

Posted on 2004-08-10
10
152 Views
Last Modified: 2013-12-24
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
Comment
Question by:theamzngq
10 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 250 total points
ID: 11765719
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
 
LVL 15

Assisted Solution

by:tim_cs
tim_cs earned 250 total points
ID: 11765736
Try this #DateCompare(DateFormat(now(), 'MM/DD/YYYY'), getDD.DueDate)#
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11767178
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
 
LVL 2

Author Comment

by:theamzngq
ID: 11767737
This seems to do exactly what I'm looking for:

#DateCompare(CreateDate(year(now()),month(now()),day(now())), getFU.FUDueDate)#
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 14

Expert Comment

by:Renante Entera
ID: 11768842
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
 
LVL 2

Author Comment

by:theamzngq
ID: 11773534
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
 
LVL 15

Expert Comment

by:tim_cs
ID: 11773781
What results did my example give you?  I tested it and it worked fine for me.
0
 
LVL 2

Author Comment

by:theamzngq
ID: 12007532
sorry for the delay, folks.  haven't been at work for a bit...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now