Coldfusion 冷融合数据逻辑

Coldfusion 冷融合数据逻辑,coldfusion,Coldfusion,我不好意思承认,在约会和约会逻辑方面,我不是最棒的 <!---checks frequency for form schedule and sets datepart. RecordType_Frequency is a column in database daily, weekly, monthly etc.---> <CFSWITCH expression="#RecordType_Frequency#"> <CFCASE value="Daily

我不好意思承认,在约会和约会逻辑方面,我不是最棒的

<!---checks frequency for form schedule and sets datepart. RecordType_Frequency is a column in database daily, weekly, monthly etc.--->

<CFSWITCH expression="#RecordType_Frequency#">
     <CFCASE value="Daily">
       <CFSET datepart = "d">
     </CFCASE>
     <CFCASE value="Weekly">
       <CFSET datepart = "ww">
     </CFCASE>
     <CFCASE value="Monthly">
       <CFSET datepart = "m">
     </CFCASE>
     <CFCASE value="Quarterly">
       <CFSET datepart = "q">
     </CFCASE>
     <CFCASE value="Yearly">
       <CFSET datepart = "yyyy">
     </CFCASE>
</CFSWITCH>

 <!---setting dates based on database values for when the form should schedule--->

 <!---enddate Uses the RecordType_Frequency_StartDate column from the database which is a date in the past. Coefficient is a stored db value for the frequency 1,2 etc. for could scheduled every 1 year, 2 year --->

 <cfset enddate = datediff(datepart,RecordType_Frequency_StartDate,todaydate) + Coefficient>

 <!---start date is set to current RecordType_Frequency_StartDate which is a column   value from the database--->

 <cfset startdate = RecordType_Frequency_StartDate>

 <!---sets the next start date for when the for should schedule based on historic db start date--->

 <cfset new_date = dateformat(DateADD(datepart,Coefficient,startdate),'MM-DD-YYYY')>

 <cfloop from="1" to="#enddate#" index="i">

   <cfset new_date = dateformat(DateADD(datepart,Coefficient,startdate),'MM-DD-YYYY')>

   <cfset startdate = new_date>

   <cfset diff = datediff(datepart,RecordType_Frequency_StartDate,startdate)>

   <cfif (startdate GT todaydate)>

      <cfset next_date= startdate>

  <cfoutput>

    <!---I need this output to equal the next date value that would fall based on the schedule, future date. I am seeing multiple dates and need to figure out how to capture would weould truly be the next scheduled date---> 

     Next Date = #diff# - #dateformat(next_date)#<br />

  </cfoutput>

 </cfif>

  </cfloop>

下一个日期=#diff#-#dateformat(下一个日期)#
总之,我有一些表格在日程表上。开始/设置日期是我必须使用的唯一日期。我需要使用我掌握的信息获取或填充表单的下一个预定日期。显然,下一个创建日期需要在将来,因为该日期将与计划的事件一起使用

我已经发布了带有注释的代码,需要帮助获取与当前日期最接近的下一个逻辑日期,该日期应按顺序排列。

如果您只需要下一个可能的日期,请使用dateadd()函数


例如,如果您希望在下一个工作日使用:
dateadd(“w”,1,now())
假设我了解您的问题,那么我不久前编写的UDF可能会解决您的问题:


在“interval”参数的其他几个选项中,它还应该接受您在开关块中使用的选项。

我不想这么说,但这可能不够清楚,无法为您找到答案。。。也许你可以把它简化为一个具有实际值的单一用例。。。这表明答案应该是什么。我在上面的代码中有点不知所措-不确定这些值应该是什么-你知道我的意思吗?似乎你真正需要的唯一一行是
new\u date=dateformat(DateADD(datepart,cocificate,startdate),'MM-DD-YYYY')
-我不确定代码的其余部分(除了开关)的用途是什么。我同意马克的观点——也许你可以发布一些真实的价值观,并试着描述一下你想要更好地完成的事情。