943,865 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Unsolved
  • Views: 2048
  • ColdFusion RSS
Sep 14th, 2009
0

dateDiff problem

Expand Post »
Hi Folks
In my db i have a datelisted column formatted to short date ie dd/mm/yyyy)

My theory is that say if that datepart year is 2007 i want to list all dates that are then due on the same date in the year 2009.

I can make this work manually by using:
coldfusion Syntax (Toggle Plain Text)
  1. <cfset getdate = Now()>
  2. <!---Get date for listing period--->
  3. <cfset renewYear = #DatePart("yyyy", getdate)# -1

What i want to do is make this dynamic. and i am trying to now is use dateDiff to work out the -1 part of the above.

I currently have:
a query as follows:
coldfusion Syntax (Toggle Plain Text)
  1. <cfquery name="getrenew" datasource="#dsn#">
  2. SELECT ID, datelisted, renewaldue, region, area, hitcount, webcount, category, busname, buscontact, busphone, mailto, paymethod
  3. FROM listings
  4. WHERE Year(datelisted) = #DatePart("yyyy", Now())# - #dateDiff("yyyy",datelisted,Now())#

in theory this should give me (as an example only)
if the year datelisted is 2007
Year(datelisted) = 2009-2

I am getting an error though that tells me that datelisted is undefined in the dateDiff function

Can anyone please help or see another way to do this

cheers and thanks in advance
Grabit
Last edited by peter_budo; Sep 16th, 2009 at 2:51 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
grabit is offline Offline
13 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: Problem in dropdown list display
Next Thread in ColdFusion Forum Timeline: Radio button problem and cfloop





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC