Calculate date

calculate the next send date. I have the survey that starts on some date and ends on some date. I need to be able to send the email every 3 days from the survey start until the survey end
LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?
 
gdemariaConnect With a Mentor Commented:
Ok, I made the assumption that the end date would be populated when it's time to stop.  

So the only change is instead of checking if the endDate is empty, check to see if the endDate has passed,  if you need to change the 3 days to a 4 or 5 days, just change the 3 in my example.   You could even set it as a field on the record..

where dateDiff(d,startDate,getDate()) % emailFrequency = 0

where startDate and emailFrequency are columns in the table and emailFrequency is a number such as 3,4, or 5...
make sure emailFrequency is a positive integer and has a value
0
 
gdemariaCommented:
I think the idea would be to figure out the number of days from the start date to today and divide by 3, if no remainder send the email

where dateDiff(d,startDate,getDate()) % 3 = 0
and  endDate is not null
1
 
erikTsomikSystem Architect, CF programmer Author Commented:
Well the messages need to go out exactly every  3 or 4 or 5 days and etc days . OS the logic will not be correct. when.

For example, every 3 days from 1/1/2018 will be 1/4/2018, 1/7/2018, 1/10/2018 and etc up until the end data for example 2/1/2018
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
erikTsomikSystem Architect, CF programmer Author Commented:
I need also use the end date so the calculation will be stopped
0
 
gdemariaCommented:
right, just make your where clause stop when the end date is past the getDate()     where endDate < getDate()
0
 
erikTsomikSystem Architect, CF programmer Author Commented:
gdemaria. is this sql expression is equal to this ColdFusion expression

<cfif dateDiff('d',dateFormat(startDate,"mmm-dd-yyyy"),DateFormat(now(), "mmm-dd-yyyy")) mod locdeliveryDays eq 0>
0
 
gdemariaCommented:
yes, but you don't need to format the dates.   DateDiff is expecting dates, formatting a date is only used for display

<cfif dateDiff('d',startDate,now()) mod locdeliveryDays eq 0>
0
 
erikTsomikSystem Architect, CF programmer Author Commented:
So will this statement be true

<cfif (dateDiff('d',startDate,now()) mod locdeliveryDays eq 0) and DateDiff('d',now(),locEndDate) gt 0>
0
 
gdemariaCommented:
it will be true depending on the value of startDate and locEndDate

It does look correct
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.