6 Replies Latest reply on Nov 22, 2015 11:47 AM by BKBK

    how do I add 7 days to a date and compare it to the current date in a cfquery?

    rickclark54 Level 1

      I have classes that are no longer active once the date of the class has passed. However, the class will need to be displayed for seven more days in the backend. I tried using the script below to accomplish this but I keep getting an error “variable DATE is undefined.” Am I heading in the right direction or is there a better way to accomplish this?

       

      <cfquery name="getClasses" datasource="#application.dsn#">

      select *

      from (classReg INNER JOIN classes ON classReg.classID = classes.classID) INNER JOIN instructors ON classreg.instID = instructors.instID

       

      <!--- adding seven days to the class date (date) comparing it to the current date --->

       

      where #DateFormat(DateAdd('d', 7, date),'yyyy-mm-dd')# > #DateFormat(now(), 'yyyy-mm-dd')#

      </cfquery>