Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2004-08-10
10
157 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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
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
 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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