Re: DateDiff() and Minutes Wierdness
Brad, On Tuesday, April 13, 2010, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 There's only 13 seconds between those two dates, so zero is the correct response. -Dan ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332900 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
Can't you just use seconds, since the difference is under a minute? cfoutput #DateDiff(s, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ On 14 April 2010 00:08, Bradley Stone b...@nb9m.com wrote: Thanks guys. I think the problem is that that I was thinking that the function could function when the arguments are essentially the same day. Here's what I did to solve the problem: when the function returns 0, do this: cfoutput cfset holdTotalHours = ABS(DatePart(h, arguments.HighDate) - DatePart(h, arguments.LowDate)) cfset holdTotalMinutes = ABS(DatePart(n, arguments.HighDate) - DatePart(n, arguments.LowDate)) Results in (HH:MM) Format: #holdTotalHours#:#holdTotalMinutes# /cfoutput Using DatePart here seems to work fine! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332901 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
Dan, There is actually 48 seconds... @Brad - I am not sure what you are trying to do, but you might consider doing the diff on seconds and converting it to the number of days, minutes seconds etc by calculating this. Plenty of examples how to turn seconds into mins, hours, days etc. On Thu, Apr 15, 2010 at 1:49 PM, Dan G. Switzer, II dswit...@pengoworks.com wrote: Brad, On Tuesday, April 13, 2010, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 There's only 13 seconds between those two dates, so zero is the correct response. -Dan ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332902 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
Um, aren't those times like 50 seconds or so apart? Isn't 50 seconds 1 minute? Therefore 0 full minutes? On Tue, Apr 13, 2010 at 7:32 AM, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 What am I missing? Any help appreciated! Brad Stone Benchmark Technologies Inc. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332851 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
teah change your evaluator to seconds and do the multiplication. On Tue, Apr 13, 2010 at 9:09 AM, Raymond Camden rcam...@gmail.com wrote: Um, aren't those times like 50 seconds or so apart? Isn't 50 seconds 1 minute? Therefore 0 full minutes? On Tue, Apr 13, 2010 at 7:32 AM, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 What am I missing? Any help appreciated! Brad Stone Benchmark Technologies Inc. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332853 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: DateDiff() and Minutes Wierdness
Isn't that: April 8th, 2010 / 19 hours 41 minutes 36 seconds April 12th, 2010 / 19 hours 10 minutes 34 seconds Around 3 days, 28 minutes, 58 seconds apart? (No coffee yet, so results may be skewed!) And what does the first decimal place in 36.0 represent, anyway? A tenth of a second? Never worked with time and decimal places. -Original Message- From: Raymond Camden [mailto:rcam...@gmail.com] Sent: Tuesday, April 13, 2010 9:09 AM To: cf-talk Subject: Re: DateDiff() and Minutes Wierdness Um, aren't those times like 50 seconds or so apart? Isn't 50 seconds 1 minute? Therefore 0 full minutes? On Tue, Apr 13, 2010 at 7:32 AM, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 What am I missing? Any help appreciated! Brad Stone Benchmark Technologies Inc. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332857 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: DateDiff() and Minutes Wierdness
Yes, the long datetime in SQL Server tracks out to fractions of seconds. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332858 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
That was his first example, which worked for him. His second example was less then 60 seconds apart. On Tue, Apr 13, 2010 at 9:37 AM, Rick Faircloth r...@whitestonemedia.com wrote: Isn't that: April 8th, 2010 / 19 hours 41 minutes 36 seconds April 12th, 2010 / 19 hours 10 minutes 34 seconds Around 3 days, 28 minutes, 58 seconds apart? (No coffee yet, so results may be skewed!) And what does the first decimal place in 36.0 represent, anyway? A tenth of a second? Never worked with time and decimal places. -Original Message- From: Raymond Camden [mailto:rcam...@gmail.com] Sent: Tuesday, April 13, 2010 9:09 AM To: cf-talk Subject: Re: DateDiff() and Minutes Wierdness Um, aren't those times like 50 seconds or so apart? Isn't 50 seconds 1 minute? Therefore 0 full minutes? On Tue, Apr 13, 2010 at 7:32 AM, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 What am I missing? Any help appreciated! Brad Stone Benchmark Technologies Inc. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332860 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: DateDiff() and Minutes Wierdness
Gotcha...I was thinking his examples were reversed... -Original Message- From: Raymond Camden [mailto:rcam...@gmail.com] Sent: Tuesday, April 13, 2010 11:55 AM To: cf-talk Subject: Re: DateDiff() and Minutes Wierdness That was his first example, which worked for him. His second example was less then 60 seconds apart. On Tue, Apr 13, 2010 at 9:37 AM, Rick Faircloth r...@whitestonemedia.com wrote: Isn't that: April 8th, 2010 / 19 hours 41 minutes 36 seconds April 12th, 2010 / 19 hours 10 minutes 34 seconds Around 3 days, 28 minutes, 58 seconds apart? (No coffee yet, so results may be skewed!) And what does the first decimal place in 36.0 represent, anyway? A tenth of a second? Never worked with time and decimal places. -Original Message- From: Raymond Camden [mailto:rcam...@gmail.com] Sent: Tuesday, April 13, 2010 9:09 AM To: cf-talk Subject: Re: DateDiff() and Minutes Wierdness Um, aren't those times like 50 seconds or so apart? Isn't 50 seconds 1 minute? Therefore 0 full minutes? On Tue, Apr 13, 2010 at 7:32 AM, Bradley Stone b...@nb9m.com wrote: All: Feeding DateDiff() dates which are more than 24 hours apart yields minutes: cfoutput #DateDiff(n, 2010-04-08 19:41:36.0, 2010-04-12 19:10:34.0)# /cfoutput Result: 5728 However, feeding DateDiff() dates which are LESS than 24 hours apart yields nothing: cfoutput #DateDiff(n, 2010-04-08 19:34:47.0, 2010-04-08 19:35:35.0)# /cfoutput Result: 0 What am I missing? Any help appreciated! Brad Stone Benchmark Technologies Inc. ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332861 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff() and Minutes Wierdness
Thanks guys. I think the problem is that that I was thinking that the function could function when the arguments are essentially the same day. Here's what I did to solve the problem: when the function returns 0, do this: cfoutput cfset holdTotalHours = ABS(DatePart(h, arguments.HighDate) - DatePart(h, arguments.LowDate)) cfset holdTotalMinutes = ABS(DatePart(n, arguments.HighDate) - DatePart(n, arguments.LowDate)) Results in (HH:MM) Format: #holdTotalHours#:#holdTotalMinutes# /cfoutput Using DatePart here seems to work fine! ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332862 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: DateDiff() and Minutes Wierdness
I was thinking that the function could function when the arguments are essentially the same day. I'm a little confused. The dateDiff() function DOES work when the arguments are the same day. Have we led you to believe otherwise, or are you talking about a different function functioning? Here's what I did to solve the problem: when the function returns 0, do this: Exactly what combination of inputs to dateDiff() is returning zero? If it is your second example in your original post, then it SHOULD return zero because the two dates were less than one minute apart. Your code below is asking whether or not the two times are in the same hour and minute which is a different question than asking how many full hours and minutes exists between the times. (It's also worth noting your code below will ONLY work for times on the same day and with a 24 hour clock) If your objective is to decide if the times are in the same minute then you should probably always be using datePart() starting with the largest unit (year) and working in and NOT using dateDiff() at all. Alternatively you could continue to use dateDiff() to the second level, divide by 60, and ceiling() the result up to the next full minute which is essentially what you are doing below. Perhaps you can explain exactly what you were trying to do. ~Brad cfoutput cfset holdTotalHours = ABS(DatePart(h, arguments.HighDate) - DatePart(h, arguments.LowDate)) cfset holdTotalMinutes = ABS(DatePart(n, arguments.HighDate) - DatePart(n, arguments.LowDate)) Results in (HH:MM) Format: #holdTotalHours#:#holdTotalMinutes# /cfoutput ~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:332864 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm