Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-14-2012, 01:14 AM   PM User | #1
Matticus03
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Matticus03 is an unknown quantity at this point
Unhappy ColdFusion Date Logic Assistance Needed

I am embarrassed to admit that I am not the greatest when it comes to dates and date logic ColdFusion.

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

In summary, I have forms that are on a schedule. The start/set up date is the only date that I have to use. I need to to grab or populate the next scheduled date for the form using what information I have. Obviously the next creation date needs to fall in the future as this date will be used in conjunction with a scheduled event.

I have posted the code with comments and need help grabbing the next logical date closest to the current date that should fall in sequence.


Any help would be very much appreciated.

Matt
Matticus03 is offline   Reply With Quote
Old 07-03-2012, 03:49 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 952
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
You are not using a mask in your DateFormat. Is next_date actually returning as a valid date?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Reply

Bookmarks

Tags
coldfusion

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:14 AM.


Advertisement
Log in to turn off these ads.