CF datediff to SQL datediff
Wondering if anyone might be able to help with this. I have products in the db that have offerStart and offerEnd dates and according to today's date they are on offer today or not, so the following works great when individually looking at the products and CF does the work: cfset today = #DateFormat(Now(),'-mm-dd')# cfif dateDiff(d, offerStart, today) GTE 0 AND dateDiff(d, today, offerEnd) GTE 0 cfset OnOffer = True cfelse cfset OnOffer = False /cfif but now I need to output ALL products in one huge list(well I'll break them down into pages) and show which one is on offer so I thought SQL should do the work. How could I 'translate' the above CF into SQL? Any help would be greatly appreciated. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349820 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: CF datediff to SQL datediff
What database are you using? -Original Message- From: Akos Fortagh [mailto:akos.fort...@yahoo.com] Sent: Wednesday, February 08, 2012 9:52 AM To: cf-talk Subject: CF datediff to SQL datediff Wondering if anyone might be able to help with this. I have products in the db that have offerStart and offerEnd dates and according to today's date they are on offer today or not, so the following works great when individually looking at the products and CF does the work: cfset today = #DateFormat(Now(),'-mm-dd')# cfif dateDiff(d, offerStart, today) GTE 0 AND dateDiff(d, today, offerEnd) GTE 0 cfset OnOffer = True cfelse cfset OnOffer = False /cfif but now I need to output ALL products in one huge list(well I'll break them down into pages) and show which one is on offer so I thought SQL should do the work. How could I 'translate' the above CF into SQL? Any help would be greatly appreciated. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349824 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF datediff to SQL datediff
thanks for the reply, I'm using mySQL ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349825 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF datediff to SQL datediff
MySQL does support dateDiff. But you could also use a simple date comparison instead. Return one (1) if the item is on offer today, or zero (0) if it is not. SELECT CASE WHEN offerStart = curDate() AND offerEnd = curDate() THEN 1 ELSE 0 END AS IsOnOffer ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349827 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: CF datediff to SQL datediff
In MySQL you can use between for finding dates that are after the first date and earlier than the second date. If you've got the first date and second date in MySQL columns you can use: where currentDate between offerStartDate and offerEndDate Try working something like that into your SQL... Rick -Original Message- From: Akos Fortagh [mailto:akos.fort...@yahoo.com] Sent: Wednesday, February 08, 2012 11:05 AM To: cf-talk Subject: Re: CF datediff to SQL datediff thanks for the reply, I'm using mySQL ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349828 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF datediff to SQL datediff
where currentDate between offerStartDate and offerEndDate Hm .. I may have misunderstood. If the goal is to retrieve *only* items that are on special, go with Rick's suggestion. -Leigh ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349830 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF datediff to SQL datediff
thank you all for the suggestions, really helpful ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349834 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
DateDiff Weirdness/Possible bug
I'm having trouble with different results for DateDiff between CF and SQL Server. I'm guessing it has something to do with DST, but it seems that CF is doing it wrong. Doing a SQL Query like this: select DateDiff(s,'1/1/1970','6/1/2011') as datediff I get 1306886400. Doing cfdump var=#DateDiff(s,'1/1/1970','6/1/2011')# I get 1306882800. Converting SQL's result back to Date using CF: #dateAdd('s',1306886400,'1/1/1970')# I get {ts '2011-06-01 01:00:00'} According to http://www.epochconverter.com/, 1306886400 is the correct number of seconds for midnight on June 1st, 2011. Is there a reason that CF is returning the wrong number of seconds? Russ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345140 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: DateDiff Weirdness/Possible bug
It looks like the times are off by 1 hour. Did you check your server's clocks to make sure they are both set to the same time? -Original Message- From: Ruslan Sivak [mailto:cfli...@ruslansivak.com] Sent: Thursday, June 09, 2011 9:43 PM To: cf-talk Subject: DateDiff Weirdness/Possible bug I'm having trouble with different results for DateDiff between CF and SQL Server. I'm guessing it has something to do with DST, but it seems that CF is doing it wrong. Doing a SQL Query like this: select DateDiff(s,'1/1/1970','6/1/2011') as datediff I get 1306886400. Doing cfdump var=#DateDiff(s,'1/1/1970','6/1/2011')# I get 1306882800. Converting SQL's result back to Date using CF: #dateAdd('s',1306886400,'1/1/1970')# I get {ts '2011-06-01 01:00:00'} According to http://www.epochconverter.com/, 1306886400 is the correct number of seconds for midnight on June 1st, 2011. Is there a reason that CF is returning the wrong number of seconds? Russ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345141 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff Weirdness/Possible bug
On 6/10/2011 12:02 PM, William Seiter wrote: It looks like the times are off by 1 hour. Did you check your server's clocks to make sure they are both set to the same time? not relevant, he's creating the datetimes, not using now(). ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345142 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: DateDiff Weirdness/Possible bug
On 6/10/2011 11:43 AM, Ruslan Sivak wrote: cfdump var=#DateDiff(s,'1/1/1970','6/1/2011')# 1st off pretty sure s won't work, DateDiff('s','1/1/1970','6/1/2011') is the correct syntax. I get 1306882800. actually i get 1306886400, my server is in ICT timezone (tz) there's no DST here. if i do createDate(2011,6,1).getTime(); i get 130686120 ms as the epoch offset. all datetimes in cf are in cf's tz. so i guess you're in tz hell. are the sql cf servers in the same tz? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345143 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Wait, I'm confused, are you trying to use the CF dateDiff() function, or a database's dateDiff() function? Actually Eric , I tried both. I'll try the quotes around TODAY see what that yields. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340843 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
I suspect dte_2dlcl is the name of a date/time column in his database. Though it shouldn't be surrounded in single quotes if that's the case. On Thu, Jan 13, 2011 at 3:23 PM, Russ Michaels r...@michaels.me.uk wrote: Thank you everyone for your input. I'm using an oracle 11g db, dte_2dlcl is a date field in the table I am working with. I need to determine the interval between two dates and need to display any records with a date interval in the range of 0 - 8, I have tried both database dateDiff() and the CF version. obviously, i am getting confused with what should be surrounded by quotes. I'll try the suggestions you all have posted and get back to you. thanks again. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340845 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Wait. I don't think Oracle 11g even has a dateDiff function. Does it? On Fri, Jan 14, 2011 at 7:53 AM, Jay Birdsell john_birds...@hotmail.comwrote: I suspect dte_2dlcl is the name of a date/time column in his database. Though it shouldn't be surrounded in single quotes if that's the case. On Thu, Jan 13, 2011 at 3:23 PM, Russ Michaels r...@michaels.me.uk wrote: Thank you everyone for your input. I'm using an oracle 11g db, dte_2dlcl is a date field in the table I am working with. I need to determine the interval between two dates and need to display any records with a date interval in the range of 0 - 8, I have tried both database dateDiff() and the CF version. obviously, i am getting confused with what should be surrounded by quotes. I'll try the suggestions you all have posted and get back to you. thanks again. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340846 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Here's what Google tells me regarding days between now() and a database column value. select extract(day from (sysdate - dte_2dlcl)) I have no idea if that's correct and can't test. I think it's a step in the right direction. Here's the reference: http://stackoverflow.com/questions/1646001/how-can-i-get-the-number-of-days-between-2-dates-in-oracle-11g On Fri, Jan 14, 2011 at 8:15 AM, Michael Grant mgr...@modus.bz wrote: Wait. I don't think Oracle 11g even has a dateDiff function. Does it? On Fri, Jan 14, 2011 at 7:53 AM, Jay Birdsell john_birds...@hotmail.comwrote: I suspect dte_2dlcl is the name of a date/time column in his database. Though it shouldn't be surrounded in single quotes if that's the case. On Thu, Jan 13, 2011 at 3:23 PM, Russ Michaels r...@michaels.me.uk wrote: Thank you everyone for your input. I'm using an oracle 11g db, dte_2dlcl is a date field in the table I am working with. I need to determine the interval between two dates and need to display any records with a date interval in the range of 0 - 8, I have tried both database dateDiff() and the CF version. obviously, i am getting confused with what should be surrounded by quotes. I'll try the suggestions you all have posted and get back to you. thanks again. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340847 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Here's what Google tells me regarding days between now() and a database column value. select extract(day from (sysdate - dte_2dlcl)) I have no idea if that's correct and can't test. I think it's a step in the right direction. Here's the reference: http://stackoverflow. com/questions/1 646001/how-can-i-get-the-number-of-days-between-2-dates-in-oracle-11g Michael, select extract(day from (sysdate - dte_2dlcl)) if run in sql plus or toad but not from with cfquery However, this works: ORACLE: cfquery name=final2 datasource=dev11g select corr_id, CAST(dte_2dlcl - #today# as integer) as draft, CAST( dte_final - #today# as integer) as final from EXECCORESP000 /cfquery The result: draft = 0, final = 3 which is correct as dte_2dlcl= 1/14/11 and dte_final = 1/17/11 CF cfquery name=final datasource=dev11g select c.* from EXECCORESP000 c /cfquery br / cfset today = #Now()# cfset draft =dateDiff('d',#today#,#final.dte_final#) This also provides the correct value. Thanks for you input. JB ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340848 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Wonderful. And just in time for the weekend. On Fri, Jan 14, 2011 at 8:33 AM, Jay Birdsell john_birds...@hotmail.comwrote: Here's what Google tells me regarding days between now() and a database column value. select extract(day from (sysdate - dte_2dlcl)) I have no idea if that's correct and can't test. I think it's a step in the right direction. Here's the reference: http://stackoverflow. com/questions/1 646001/how-can-i-get-the-number-of-days-between-2-dates-in-oracle-11g Michael, select extract(day from (sysdate - dte_2dlcl)) if run in sql plus or toad but not from with cfquery However, this works: ORACLE: cfquery name=final2 datasource=dev11g select corr_id, CAST(dte_2dlcl - #today# as integer) as draft, CAST( dte_final - #today# as integer) as final from EXECCORESP000 /cfquery The result: draft = 0, final = 3 which is correct as dte_2dlcl= 1/14/11 and dte_final = 1/17/11 CF cfquery name=final datasource=dev11g select c.* from EXECCORESP000 c /cfquery br / cfset today = #Now()# cfset draft =dateDiff('d',#today#,#final.dte_final#) This also provides the correct value. Thanks for you input. JB ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340849 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
help w/ DateDiff() please
The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340770 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Is dte_2dlcl a column in the database? You can't execute a ColdFusion function on a database column in a query. Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com On 1/13/2011 1:41 PM, Jay Birdsell wrote: The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340771 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
try # 1:: select dateDiff('d',#today#,'dte_2dlcl') as Results:: Error - DateDiff invalid identifier If you are trying to use MS SQL's function, it does not allow quotes around the datepart. So it would just be: d not 'd' (in quotes). Also if dte_2dlcl is a column name, remove the quotes or your database will think it is a literal string. ie dateDiff('d', today, 'dte_2dlcl') http://msdn.microsoft.com/en-us/library/ms189794.aspx - Leigh http://cfsearching.blogspot.com/ --- On Thu, 1/13/11, Jay Birdsell john_birds...@hotmail.com wrote: From: Jay Birdsell john_birds...@hotmail.com Subject: help w/ DateDiff() please To: cf-talk cf-talk@houseoffusion.com Date: Thursday, January 13, 2011, 7:41 PM The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340772 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
Wait, I'm confused, are you trying to use the CF dateDiff() function, or a database's dateDiff() function? If you're using a database's, then I think you need to wrap #today# in quotes. Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com On 1/13/2011 1:53 PM, Eric Cobb wrote: Is dte_2dlcl a column in the database? You can't execute a ColdFusion function on a database column in a query. Thanks, Eric Cobb ECAR Technologies, LLC http://www.ecartech.com http://www.cfgears.com On 1/13/2011 1:41 PM, Jay Birdsell wrote: The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340773 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
a database's dateDiff() function? If you're using a database's, then I think you need to wrap #today# in quotes. Depends on whether it is a date string or date object. Though using cfqueryparam would negate the need for quotes. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340776 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: help w/ DateDiff() please
Well dte_2dlcl is not a valid enddate for a start. You also need to make sure the dates are in the proper format the database understands. If your using sql server http://msdn.microsoft.com/en-us/library/aa258269%28v=sql.80%29.aspx Russ -Original Message- From: Jay Birdsell [mailto:john_birds...@hotmail.com] Sent: 13 January 2011 19:41 To: cf-talk Subject: help w/ DateDiff() please The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340778 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
I suspect dte_2dlcl is the name of a date/time column in his database. Though it shouldn't be surrounded in single quotes if that's the case. On Thu, Jan 13, 2011 at 3:23 PM, Russ Michaels r...@michaels.me.uk wrote: Well dte_2dlcl is not a valid enddate for a start. You also need to make sure the dates are in the proper format the database understands. If your using sql server http://msdn.microsoft.com/en-us/library/aa258269%28v=sql.80%29.aspx Russ -Original Message- From: Jay Birdsell [mailto:john_birds...@hotmail.com] Sent: 13 January 2011 19:41 To: cf-talk Subject: help w/ DateDiff() please The dateDiff () is killing me! can someone please look at this and help me clear my head. What I have is a db that tracks executive correspondence when drafts are due and when the final response is due. I need a report that will list any correspondence that has a draft or final date within 8 days of the run date (today). I've read that i should be able to do this right in the select statement. However I have found a clean concise example here is what I have tried so far; try # 1:: cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 /cfquery Results:: Error - DateDiff invalid identifier try# 2 cfquery name=final8 datasource=dev11g select dateDiff('d',#today#,'dte_2dlcl') as m from execcoresp000 where m 8 /cfquery Results: Error M invalid identifier try # 3 cfquery name=final8 datasource=dev11g select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 /cfquery Results: Error - DateDiff invalid identifier The other error i tend to get is Missing right parenthese i really dont want to get in a bunch of nested loops to do this. any ideas? tia, jbird ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340779 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: help w/ DateDiff() please
try # 3 select dte_2dlcl from execcoresp000.correspondence where dateDiff('d',#today#,'dte_2dlcl') 8 Keep in mind it is often more efficient to rewrite the query using a basic date comparison. (Functions can sometimes impede the database's use of indexes.) The syntax depends what you mean by within 8 days and whether your column stores a date only or a date and time. Some examples are: ie - WHERE SomeDateColumn cfqueryparam value=#someDate# cfsqltype=cf_sql_timestamp ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340780 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
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
DateDiff() and Minutes Wierdness
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:332850 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
ColdFusion dateDiff() function?
Okay, I am probably splitting hairs over here, but I ran into an icky situation with the native ColdFusion function DateDiff() today and just thought I'd check whether anyone else has experienced this before. Basically, I wrote a CF Scheduled Task that is supposed to go to a directory and delete all PDF files that are created before today. Simple enough, right? It should be really, but the DateDiff() function is behaving strangely. Try running the code below: cfset variables.yesterday = 04-04-2010 11:59 PM cfset variables.today = 04-05-2010 12:01 AM cfoutputtoday - yesterday = #dateDiff(d,yesterday,today)#/cfoutput You see how it thinks the the date difference is ZERO??? Shouldn't it be ONE???!!! There are ways to get around this (elegantly or otherwise)... but now I am just irked and curious. Is this expected behavior and I am just not understanding the function correctly or is this a bug that should get fixed? ~| 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:332613 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ColdFusion dateDiff() function?
Nope, it's working as designed. Here is an excerpt from the docs: The DateDiff function determines the number of complete datepart units between the two dates; for example, if the datepart parameter is m and the dates differ by 55 days, the function returns 1. So basically, using date diff is like using the floor operator, it is only counting the total number of COMPLETE days. Your example has a difference of only 2 minutes which is nowhere near a day. If you simply want to know if the files were created prior to midnight of the current day, then you should check for that specifically with something like so: cfset variables.yesterday = 04-04-2010 11:59 PM cfset variables.today = 04-05-2010 12:01 AM cfoutput#yesterday LT dateformat(today,mm/dd/)#/cfoutput - Original Message - From: Qing Xia txiasum...@gmail.com To: cf-talk cf-talk@houseoffusion.com Sent: Monday, April 05, 2010 9:05 PM Subject: ColdFusion dateDiff() function? Okay, I am probably splitting hairs over here, but I ran into an icky situation with the native ColdFusion function DateDiff() today and just thought I'd check whether anyone else has experienced this before. Basically, I wrote a CF Scheduled Task that is supposed to go to a directory and delete all PDF files that are created before today. Simple enough, right? It should be really, but the DateDiff() function is behaving strangely. Try running the code below: cfset variables.yesterday = 04-04-2010 11:59 PM cfset variables.today = 04-05-2010 12:01 AM cfoutputtoday - yesterday = #dateDiff(d,yesterday,today)#/cfoutput You see how it thinks the the date difference is ZERO??? Shouldn't it be ONE???!!! There are ways to get around this (elegantly or otherwise)... but now I am just irked and curious. Is this expected behavior and I am just not understanding the function correctly or is this a bug that should get fixed? ~| 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:332615 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ColdFusion dateDiff() function?
If only two minutes separate timestamps, that is less than a day from my perspective, so the value should be 0. If 24 hours separate the two timestamps, that would be a one day difference. There are plenty of solutions to the problem. One is to remove the time element before doing the comparison. The best solution would depend on what you are trying to achieve, which I could only guess at. -Mike Chabot On Mon, Apr 5, 2010 at 10:05 PM, Qing Xia txiasum...@gmail.com wrote: Okay, I am probably splitting hairs over here, but I ran into an icky situation with the native ColdFusion function DateDiff() today and just thought I'd check whether anyone else has experienced this before. Basically, I wrote a CF Scheduled Task that is supposed to go to a directory and delete all PDF files that are created before today. Simple enough, right? It should be really, but the DateDiff() function is behaving strangely. Try running the code below: cfset variables.yesterday = 04-04-2010 11:59 PM cfset variables.today = 04-05-2010 12:01 AM cfoutputtoday - yesterday = #dateDiff(d,yesterday,today)#/cfoutput You see how it thinks the the date difference is ZERO??? Shouldn't it be ONE???!!! There are ways to get around this (elegantly or otherwise)... but now I am just irked and curious. Is this expected behavior and I am just not understanding the function correctly or is this a bug that should get fixed? ~| 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:332616 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ColdFusion dateDiff() function?
Hmm... thanks Brad and Mike for your quick replies. I have thought about your answers deeply and decided they do make sense. :-) I read the CF Docs too quickly and made the assumption (never good to assume!) that the CF dateDiff() function works the same way as the SQL dateDiff() function, which says: When the user tells me where to look, I only look at that value. So a specified d means disregard the hour and minute values, and just return the difference in days. Thanks again for your input! On Mon, Apr 5, 2010 at 10:41 PM, Mike Chabot mcha...@gmail.com wrote: If only two minutes separate timestamps, that is less than a day from my perspective, so the value should be 0. If 24 hours separate the two timestamps, that would be a one day difference. There are plenty of solutions to the problem. One is to remove the time element before doing the comparison. The best solution would depend on what you are trying to achieve, which I could only guess at. -Mike Chabot On Mon, Apr 5, 2010 at 10:05 PM, Qing Xia txiasum...@gmail.com wrote: Okay, I am probably splitting hairs over here, but I ran into an icky situation with the native ColdFusion function DateDiff() today and just thought I'd check whether anyone else has experienced this before. Basically, I wrote a CF Scheduled Task that is supposed to go to a directory and delete all PDF files that are created before today. Simple enough, right? It should be really, but the DateDiff() function is behaving strangely. Try running the code below: cfset variables.yesterday = 04-04-2010 11:59 PM cfset variables.today = 04-05-2010 12:01 AM cfoutputtoday - yesterday = #dateDiff(d,yesterday,today)#/cfoutput You see how it thinks the the date difference is ZERO??? Shouldn't it be ONE???!!! There are ways to get around this (elegantly or otherwise)... but now I am just irked and curious. Is this expected behavior and I am just not understanding the function correctly or is this a bug that should get fixed? ~| 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:332617 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ColdFusion dateDiff() function?
The easiest solution would be to remove the time stamp of the compare. On Tue, Apr 6, 2010 at 12:50 PM, Qing Xia txiasum...@gmail.com wrote: Hmm... thanks Brad and Mike for your quick replies. I have thought about your answers deeply and decided they do make sense. :-) I read the CF Docs too quickly and made the assumption (never good to assume!) that the CF dateDiff() function works the same way as the SQL dateDiff() function, which says: When the user tells me where to look, I only look at that value. So a specified d means disregard the hour and minute values, and just return the difference in days. Thanks again for your input! ~| 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:332620 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: CF DATEDIFF Function
You should be able to do: fix(tomorrow) - fix(now()) = diff in days CF stores dates as a float, where the integer is the day value and the decimal values are represent the time. So, if you just round down and subtract the two dates you'll get the difference in whole days. -Dan -Original Message- From: Dawson, Michael [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 04, 2008 8:02 AM To: cf-talk Subject: RE: CF DATEDIFF Function Exactly. An entire day must expire before it can be counted. To expand that, an entire time period must expire before it can be counted. This includes years, months, days, hours, minutes, seconds, etc. If you want to count today, just add one or use a different time period as Paul suggests. Mike -Original Message- From: Paul Hastings [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 8:39 PM To: cf-talk Subject: Re: CF DATEDIFF Function Azadi Saryev wrote: because your server time is different from your computer's time? your well there's that or that dateDiff returns results for *whole* days (or whatever). try using hours. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314806 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF DATEDIFF Function
Exactly. An entire day must expire before it can be counted. To expand that, an entire time period must expire before it can be counted. This includes years, months, days, hours, minutes, seconds, etc. If you want to count today, just add one or use a different time period as Paul suggests. Mike -Original Message- From: Paul Hastings [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 8:39 PM To: cf-talk Subject: Re: CF DATEDIFF Function Azadi Saryev wrote: because your server time is different from your computer's time? your well there's that or that dateDiff returns results for *whole* days (or whatever). try using hours. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314804 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CF DATEDIFF Function
As others have pointed out, it's an issue of Whole Days. Think of it this way, you are testing number of days between Now() and tomorrow's date, right? Well, Now() includes the time, so not just '11/04/2008', but right now it's '11/04/2008 08:06 EST'. When you test that against '11/05/2008', without a time, the system assumes midnight, so '11/05/2008 00:00 EST'. [Assuming that the server is in US Eastern time zone, for the purposes of the demonstration.] From 08:06 until the next 00:00 is less than 24 hours, so it's Zero Whole Days. HTH, Jason Hi, Can anybody explain why the return value is '0' when determining the difference in dates between today and tommorow? IE... cfset showdiff = #datediff('d',now(),'11/04/2008')# cfdump var=#showdiff# What i interpret from the datediff statement is that I need the difference in (days) between now() which is 11/03/2008 and 11/04/2008... Should be 1...Keep getting 0. Any ideas? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314805 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
CF DATEDIFF Function
Hi, Can anybody explain why the return value is '0' when determining the difference in dates between today and tommorow? IE... cfset showdiff = #datediff('d',now(),'11/04/2008')# cfdump var=#showdiff# What i interpret from the datediff statement is that I need the difference in (days) between now() which is 11/03/2008 and 11/04/2008...Should be 1...Keep getting 0. Any ideas? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314793 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CF DATEDIFF Function
because your server time is different from your computer's time? your server may be in a timezone where it is already 'tomorrow' while where you are it is still 'today', so now() on the server will return your 'tomorrow' date... Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ LSD 4Me wrote: Hi, Can anybody explain why the return value is '0' when determining the difference in dates between today and tommorow? IE... cfset showdiff = #datediff('d',now(),'11/04/2008')# cfdump var=#showdiff# What i interpret from the datediff statement is that I need the difference in (days) between now() which is 11/03/2008 and 11/04/2008...Should be 1...Keep getting 0. Any ideas? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314795 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CF DATEDIFF Function
Azadi Saryev wrote: because your server time is different from your computer's time? your well there's that or that dateDiff returns results for *whole* days (or whatever). try using hours. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314797 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CF DATEDIFF Function
Problem is that im not storing time with the date... Also, the return value is '0' for today, and tommorow...i.e Today #datediff(d,now(),now())# Tommorow #datediff(d,now(),now()+1)# I managed to resolve this with another solution... cfset currentdate = #dateformat(now(),'mm,dd,')# cfset ddiff = (#currentdate# - #db_data#) This returns the INT values i need to begin with (-,0,+) Thanks neways! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314798 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CF DATEDIFF Function
it's a bad idea to store dates in your db as text. store them as dates. Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ LSD 4Me wrote: Problem is that im not storing time with the date... Also, the return value is '0' for today, and tommorow...i.e Today #datediff(d,now(),now())# Tommorow #datediff(d,now(),now()+1)# I managed to resolve this with another solution... cfset currentdate = #dateformat(now(),'mm,dd,')# cfset ddiff = (#currentdate# - #db_data#) This returns the INT values i need to begin with (-,0,+) Thanks neways! ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314799 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Why datediff
As an aside, I wouldn't use number as a variable name. Just instinct, but it seems likely that there might be conflicts along the line with reserved words etc.. -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: 19 December 2006 01:09 To: CF-Talk Subject: Re: Why datediff CreateODBCDateTime(dateformat(12/12/2006 1:36:51 PM, MM/DD/)) should be a valid date/time object. No more: CreateODBCDateTime expects a date/time object, not a formated string. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264416 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Why datediff
Why is this not working? CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput ERROR The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Missing argument name. When using named parameters to a function, every parameter must have a name. The CFML compiler was processing: an expression beginning with #, on line 9, column 17.This message is usually caused by a problem in the expressions structure. a CFSET tag beginning on line 9, column 2. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264384 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Why datediff
1: you don't need # inside cfset unless you're in a string. 2: you need ticks around d ('d') [EMAIL PROTECTED] wrote: Why is this not working? CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput ERROR The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Missing argument name. When using named parameters to a function, every parameter must have a name. The CFML compiler was processing: an expression beginning with #, on line 9, column 17.This message is usually caused by a problem in the expressions structure. a CFSET tag beginning on line 9, column 2. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264385 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Why datediff
CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput You need some quotes in there. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264386 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Why datediff
don't believe you need the dateFormat() either. dateDiff doesn't particularly care what format a date's in. cfset number = dateDiff('d', createDate(2006, 12, 12), now()) / On 12/18/06, Jake Churchill [EMAIL PROTECTED] wrote: 1: you don't need # inside cfset unless you're in a string. 2: you need ticks around d ('d') [EMAIL PROTECTED] wrote: Why is this not working? CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput ERROR The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Missing argument name. When using named parameters to a function, every parameter must have a name. The CFML compiler was processing: an expression beginning with #, on line 9, column 17.This message is usually caused by a problem in the expressions structure. a CFSET tag beginning on line 9, column 2. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264387 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Why datediff
because, dateformat(12/12/2006 1:36:51 PM, MM/DD/) is not a date/time object. Now, CreateODBCDateTime(dateformat(12/12/2006 1:36:51 PM, MM/DD/)) should be a valid date/time object. Or, you might be able to say: dateformat(12/12/2006 1:36:51 PM, MM/DD/) and get your desired results, but then if CF recognizes 12/12/2006 1:36:51 PM as a valid date/time object (and I believe it does), then there'd be no point in doing the dateformat. just do the date diff like this: CFSET number = DateDiff(d, 12/12/2006 1:36:51 PM, now()) cfoutput#number#/cfoutput Give that a whirl. Also, when you're in a tag like CFSet you do not need to put pounds around your variables unless you're dynamically evaluating them. hope that helps, Cheers, Chris [EMAIL PROTECTED] wrote: Why is this not working? CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput ERROR The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Missing argument name. When using named parameters to a function, every parameter must have a name. The CFML compiler was processing: an expression beginning with #, on line 9, column 17.This message is usually caused by a problem in the expressions structure. a CFSET tag beginning on line 9, column 2. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264388 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Why datediff
Good catch Jake. It's something that Ian and I both missed. You definitely have to have quotes around the date part (d). I prefer double quotes, but do whatever you like. Also, there's still no reason to do the dateformat statements. Cheers, Chris Ian Skinner wrote: CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput You need some quotes in there. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264389 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Why datediff
And no reason for all of those pound signs, guys. cfset number = dateDiff(d, 12/12/2006,now()) You should lower case your tags as well :) Yeah, I know, I'm a code naazy. -Original Message- From: Christopher Jordan [mailto:[EMAIL PROTECTED] Sent: Monday, December 18, 2006 5:04 PM To: CF-Talk Subject: Re: Why datediff Good catch Jake. It's something that Ian and I both missed. You definitely have to have quotes around the date part (d). I prefer double quotes, but do whatever you like. Also, there's still no reason to do the dateformat statements. Cheers, Chris Ian Skinner wrote: CFSET number = #DateDiff(d, dateformat(12/12/2006 1:36:51 PM, MM/DD/), dateformat(now(), MM/DD/) )# cfoutput#number#/cfoutput You need some quotes in there. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA - | 1 | | - Binary Soduko | | | - C code. C code run. Run code run. Please! - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264394 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Why datediff
dateDiff doesn't particularly care what format a date's in. Yes it does. It expects date values, not formated strings. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264404 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Why datediff
CreateODBCDateTime(dateformat(12/12/2006 1:36:51 PM, MM/DD/)) should be a valid date/time object. No more: CreateODBCDateTime expects a date/time object, not a formated string. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264405 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
DateDiff bug, or am I stupid?
I brought this up in a previous thread: http://www.houseoffusion.com/groups/CF-Talk/thread.cfm/threadid:49106 If you execute this code, changing the 'currentHour' at the top to the current hour in your time zone, tell me if diff1 isn't way off (it should be 0): cfset currentHour = 2 cfset date1 = createDateTime(year(now()), month(now()), day(now()), currentHour, minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff1 = DateDiff(s,date1,now()) cfset date2 = createDateTime(year(now()), month(now()), day(now()), hour(now()), minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff2 = DateDiff(s,date2,now()) cfoutput date1: #date1#br / diff1: #diff1#br / date2: #date2#br / diff2: #diff2# /cfoutput The problem I'm seeing is that the hour from date1 is on the 12 hour clock, while date2's hour is on the 24 hour clock. I'd think CF would be able to correctly parse that. Or am I getting something confused? I already know how to work around this, I'm just curious about this weird behavior. On a side note, I tried this on both ColdFusion and BlueDragon and get the same results, which makes me think I'm not getting something. -- My Sites: http://www.techfeed.net/blog/ http://www.cfquickdocs.com/ http://cfformprotect.riaforge.org/ ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263863 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: DateDiff bug, or am I stupid?
Yeah, if I change the DateDiff to d it tells me there is a 12 hour difference. If I do like so, it is right cfset date1 = createODBCDateTime(Now()) !--- calculate how many seconds elapsed --- cfset diff1 = DateDiff(h,date1,now()) - Original Message - From: Jacob Munson [EMAIL PROTECTED] To: CF-Talk cf-talk@houseoffusion.com Sent: Tuesday, December 12, 2006 3:33 PM Subject: DateDiff bug, or am I stupid? I brought this up in a previous thread: http://www.houseoffusion.com/groups/CF-Talk/thread.cfm/threadid:49106 If you execute this code, changing the 'currentHour' at the top to the current hour in your time zone, tell me if diff1 isn't way off (it should be 0): cfset currentHour = 2 cfset date1 = createDateTime(year(now()), month(now()), day(now()), currentHour, minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff1 = DateDiff(s,date1,now()) cfset date2 = createDateTime(year(now()), month(now()), day(now()), hour(now()), minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff2 = DateDiff(s,date2,now()) cfoutput date1: #date1#br / diff1: #diff1#br / date2: #date2#br / diff2: #diff2# /cfoutput The problem I'm seeing is that the hour from date1 is on the 12 hour clock, while date2's hour is on the 24 hour clock. I'd think CF would be able to correctly parse that. Or am I getting something confused? I already know how to work around this, I'm just curious about this weird behavior. On a side note, I tried this on both ColdFusion and BlueDragon and get the same results, which makes me think I'm not getting something. -- My Sites: http://www.techfeed.net/blog/ http://www.cfquickdocs.com/ http://cfformprotect.riaforge.org/ ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263868 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: DateDiff bug, or am I stupid?
The problem is that you cannot give the CreateDateTime function a '5' and expect it to know if you mean AM or PM. The function works only with a 24 hour clock. pass it a seventeen (which your second case does since hour(now()) equals 17 not 5), and everything works fine. It's not a bug, just some confusion. Hope this helps! :o) Cheers, Chris Jacob Munson wrote: I brought this up in a previous thread: http://www.houseoffusion.com/groups/CF-Talk/thread.cfm/threadid:49106 If you execute this code, changing the 'currentHour' at the top to the current hour in your time zone, tell me if diff1 isn't way off (it should be 0): cfset currentHour = 2 cfset date1 = createDateTime(year(now()), month(now()), day(now()), currentHour, minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff1 = DateDiff(s,date1,now()) cfset date2 = createDateTime(year(now()), month(now()), day(now()), hour(now()), minute(now()), second(now())) !--- calculate how many seconds elapsed --- cfset diff2 = DateDiff(s,date2,now()) cfoutput date1: #date1#br / diff1: #diff1#br / date2: #date2#br / diff2: #diff2# /cfoutput The problem I'm seeing is that the hour from date1 is on the 12 hour clock, while date2's hour is on the 24 hour clock. I'd think CF would be able to correctly parse that. Or am I getting something confused? I already know how to work around this, I'm just curious about this weird behavior. On a side note, I tried this on both ColdFusion and BlueDragon and get the same results, which makes me think I'm not getting something. ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263872 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: DateDiff bug, or am I stupid?
The problem is that you cannot give the CreateDateTime function a '5' and expect it to know if you mean AM or PM. The function works only with a 24 hour clock. pass it a seventeen (which your second case does since hour(now()) equals 17 not 5), and everything works fine. I guess I missed the part in the docs that says the 'hour' part of CreateDateTime is 24 hour. :) -- My Sites: http://www.techfeed.net/blog/ http://www.cfquickdocs.com/ http://cfformprotect.riaforge.org/ ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263874 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: DateDiff bug, or am I stupid?
Meh, no worries mate! ;o) I was going to suggest that you write a UDF that would handle it the way you expect, but then I thought that's probably more trouble than it's worth. :o) Cheers, Chris Jacob Munson wrote: The problem is that you cannot give the CreateDateTime function a '5' and expect it to know if you mean AM or PM. The function works only with a 24 hour clock. pass it a seventeen (which your second case does since hour(now()) equals 17 not 5), and everything works fine. I guess I missed the part in the docs that says the 'hour' part of CreateDateTime is 24 hour. :) ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263876 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
DateDiff weirdness
I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262130 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: DateDiff weirdness
Show us the code! On 11/29/06, Munson, Jacob [EMAIL PROTECTED] wrote: I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262134 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: DateDiff weirdness
Try making them BOTH createDateTime() values THEN using datediff() on those values. If that doesnt work, try this... cfset firstdate = 20061129041148 / cfset seconddate = dateformat(now(), 'mmdd') timeformat(now(), 'hhmmss') / cfset diff = secondate - firstdate / ..:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Munson, Jacob [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:17 PM To: CF-Talk Subject: DateDiff weirdness I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262135 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: DateDiff weirdness
Seems to work, the following returns 9, as it should cfset s1=20061129041148 cfset s2=20061129041157 cfset d1=CreateDateTime(Left(s1, 4), Mid(s1, 5, 2), Mid(s1, 7, 2), Mid(s1, 9, 2), Mid(s1, 11, 2), Mid(s1, 13, 2)) cfset d2=CreateDateTime(Left(s2, 4), Mid(s2, 5, 2), Mid(s2, 7, 2), Mid(s2, 9, 2), Mid(s2, 11, 2), Mid(s2, 13, 2)) cfoutput #DateDiff(s, d1, d2)# /cfoutput --- Ben -Original Message- From: Munson, Jacob [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:17 PM To: CF-Talk Subject: DateDiff weirdness I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262138 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: DateDiff weirdness
Try making them BOTH createDateTime() values THEN using datediff() on those values. Both now() and createDateTime return date/time objects, so that shouldn't matter. If that doesn't work, try this... cfset firstdate = 20061129041148 / cfset seconddate = dateformat(now(), 'mmdd') timeformat(now(), 'hhmmss') / cfset diff = secondate - firstdate / At first, I thought that was a good idea, but it wouldn't work if the two values are different in anything greater than the seconds. EMF idahopower.com made the following annotations. -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262141 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: DateDiff weirdness
I think you will have to do Ben's parsing as below if you have the dates in that format 20061129041148. Using CreateODBCDateTime or CreateDateTime on that string as it stands does not return the desired result. -- Josh - Original Message - From: Ben Forta [EMAIL PROTECTED] To: CF-Talk cf-talk@houseoffusion.com Sent: Wednesday, November 29, 2006 3:29 PM Subject: RE: DateDiff weirdness Seems to work, the following returns 9, as it should cfset s1=20061129041148 cfset s2=20061129041157 cfset d1=CreateDateTime(Left(s1, 4), Mid(s1, 5, 2), Mid(s1, 7, 2), Mid(s1, 9, 2), Mid(s1, 11, 2), Mid(s1, 13, 2)) cfset d2=CreateDateTime(Left(s2, 4), Mid(s2, 5, 2), Mid(s2, 7, 2), Mid(s2, 9, 2), Mid(s2, 11, 2), Mid(s2, 13, 2)) cfoutput #DateDiff(s, d1, d2)# /cfoutput --- Ben -Original Message- From: Munson, Jacob [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:17 PM To: CF-Talk Subject: DateDiff weirdness I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262144 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: DateDiff weirdness
I found the problem. My original date was using the 12 hour clock, but now() was returning a value from the 24 hour clock. I'm not sure why that caused dateDiff to return bad results, but it did. -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262145 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: DateDiff weirdness
This won't work if difference greater than 59secs, or 2nd seconds less greater than 1st seconds. -Original Message- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:26 PM To: CF-Talk Subject: RE: DateDiff weirdness Try making them BOTH createDateTime() values THEN using datediff() on those values. If that doesnt work, try this... cfset firstdate = 20061129041148 / cfset seconddate = dateformat(now(), 'mmdd') timeformat(now(), 'hhmmss') / cfset diff = secondate - firstdate / ...:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Munson, Jacob [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 6:17 PM To: CF-Talk Subject: DateDiff weirdness I have a date value in this format: mmddhhmmss, for example 20061129041148. What I need to do is calculate the difference in seconds between this date and now(). So I figured I'd use createDateTime() to turn it into a valid date/time object, and then use dateDiff(). However, doing that I get a huge difference returned, like 43529, when there are truly only 5 seconds between the two date/times. Any ideas? -- This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. == EMF idahopower.com made the previous annotations. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262146 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: DateDiff weirdness
Bobby Hartsfield wrote: cfset firstdate = 20061129041148 / numeric dates in cf have to be in decimal days since cf's epoch (dec-31-1899). you have to parse that turn it into a cf datetme object. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262147 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: DateDiff weirdness
Yep. I was going for the difference between two numbers... not seconds between two actual dates sorry. ..:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Paul Hastings [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 29, 2006 7:02 PM To: CF-Talk Subject: Re: DateDiff weirdness Bobby Hartsfield wrote: cfset firstdate = 20061129041148 / numeric dates in cf have to be in decimal days since cf's epoch (dec-31-1899). you have to parse that turn it into a cf datetme object. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262152 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
DateDiff Error Rrrrrrr
All, I'm trying to fix someone's code and I'm getting this error within a datediff. When I do a cfdump on the query variable UserCoupon.LastDownloadDate I get [empty string]. However when I do the query myself I get a single record returned. Is there something wrong with this syntax. This code was originally written against MSAccess, it's been since moved to SQL Server. Any help would be much appreciated. Error starts with ... Null Pointers are another name for undefined values. The error occurred in D:\Inetpub\wwwroot\site\website\coupons\viewcoupons.cfm: line 184 182 : CFSET CouponFlag = 0 183 : CFELSE 184 : CFIF DateDiff('D', UserCoupon.LastDownloadDate, (DateFormat(Now(),mm/dd/))) GTE Coupons.RefreshDays 185 : CFSET CouponFlag = 0 186 : /CFIF Here's the actual cf code. (Not my code) CFQUERY Name=Coupons datasource=ds select *from Couponswhere StartDate = #CreateODBCDateTime(now())# and EndDate = #CreateODBCDateTime(now())#and CompanyID = 1 order by CouponOrder ASC /CFQUERY CFOUTPUT Query=Coupons CFQUERY datasource=ds Name=UserCoupon select * from UserCoupons where UserID = #cookie.userID# and CouponID = #Coupons.ID# /CFQUERY MY TROUBLESHOOTING LASTD:CFDUMP var=#UserCoupon.LastDownloadDate# label=userlastdown expand=yesbr COOKIE.USERID:CFDUMP var=#cookie.userID# label=userlastdown expand=yesbr COUPON ID:CFDUMP var=#Coupons.ID# label=userlastdown expand=yesbr RESULTS: UserCoupon.LastDownloadDate CFDUMP = [empty string] COOKIE.USERID: 24884 COUPON ID: 269 MY TROUBLESHOOTING CFIF UserCoupon.RecordCount EQ 0 CFSET CouponFlag = 0 CFELSE ERROR HAPPENS HERE CFIF DateDiff('D', UserCoupon.LastDownloadDate, (DateFormat(Now(),mm/dd/))) GTE Coupons.RefreshDays ERROR HAPPENS HERE CFSET CouponFlag = 0 /CFIF /CFIF /CFOUTPUT ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259670 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: DateDiff Error Rrrrrrr
Coupons.RefreshDays below is set to 9 as a constant. D All, ERROR HAPPENS HERE CFIF DateDiff('D', UserCoupon.LastDownloadDate, (DateFormat(Now(), mm/dd/))) GTE Coupons.RefreshDays ERROR HAPPENS HERE ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259672 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: DateDiff Error Rrrrrrr
It looks like LastDownloadDate is just NULL in the database. .. Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com Need ColdFusion Help? www.bennadel.com/ask-ben/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 08, 2006 12:48 PM To: CF-Talk Subject: DateDiff Error Rrr All, I'm trying to fix someone's code and I'm getting this error within a datediff. When I do a cfdump on the query variable UserCoupon.LastDownloadDate I get [empty string]. However when I do the query myself I get a single record returned. Is there something wrong with this syntax. This code was originally written against MSAccess, it's been since moved to SQL Server. Any help would be much appreciated. Error starts with ... Null Pointers are another name for undefined values. The error occurred in D:\Inetpub\wwwroot\site\website\coupons\viewcoupons.cfm: line 184 182 : CFSET CouponFlag = 0 183 : CFELSE 184 : CFIF DateDiff('D', UserCoupon.LastDownloadDate, (DateFormat(Now(),mm/dd/))) GTE Coupons.RefreshDays 185 : CFSET CouponFlag = 0 186 : /CFIF Here's the actual cf code. (Not my code) CFQUERY Name=Coupons datasource=ds select *from Coupons where StartDate = #CreateODBCDateTime(now())# and EndDate = #CreateODBCDateTime(now())#and CompanyID = 1 order by CouponOrder ASC /CFQUERY CFOUTPUT Query=Coupons CFQUERY datasource=ds Name=UserCoupon select * from UserCoupons where UserID = #cookie.userID# and CouponID = #Coupons.ID# /CFQUERY MY TROUBLESHOOTING LASTD:CFDUMP var=#UserCoupon.LastDownloadDate# label=userlastdown expand=yesbr COOKIE.USERID:CFDUMP var=#cookie.userID# label=userlastdown expand=yesbr COUPON ID:CFDUMP var=#Coupons.ID# label=userlastdown expand=yesbr RESULTS: UserCoupon.LastDownloadDate CFDUMP = [empty string] COOKIE.USERID: 24884 COUPON ID: 269 MY TROUBLESHOOTING CFIF UserCoupon.RecordCount EQ 0 CFSET CouponFlag = 0 CFELSE ERROR HAPPENS HERE CFIF DateDiff('D', UserCoupon.LastDownloadDate, (DateFormat(Now(),mm/dd/))) GTE Coupons.RefreshDays ERROR HAPPENS HERE CFSET CouponFlag = 0 /CFIF /CFIF /CFOUTPUT ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259674 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Datediff help
I have a query where I'm performing an inner join and the cfm page is telling me ... MembShpDate is an existiing column in the MemberDetails table and it's a valid datetime datatype. Any ideas? Full cfquery is after error message. The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Element MEMBSHPDATE is undefined in MEB. The error occurred in C:\CFusionMX7\wwwroot\PipeLine\Pipe_SchoolCoun\rm\reportMemberReg.cfm: line 31 29 : cfquery name=getReg datasource=#app.ds# timeout=120 30 :SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB, MEB.MembShpDate, ON ORD.UserID = MEB.MemberAutoID 31 :WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 32 :AND ORD.Deleted = 0 33 :AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') here is the full query. cfquery name=getReg datasource=#app.ds# timeout=120 SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB ON ORD.UserID = MEB.MemberAutoID WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 AND ORD.Deleted = 0 AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') ORDER BY MEB.MembShpDate DESC /cfquery ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250092 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Datediff help
In this context, #DateDiff()# is a ColdFusion function. If you want the database's DateDiff() function, remove the #s. The error occurs because CF thinks it is parsing a CF variable, MEB.MembShpDate but there is no structure named MEB. M!ke -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 16, 2006 8:24 PM To: CF-Talk Subject: Datediff help I have a query where I'm performing an inner join and the cfm page is telling me ... MembShpDate is an existiing column in the MemberDetails table and it's a valid datetime datatype. Any ideas? Full cfquery is after error message. The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Element MEMBSHPDATE is undefined in MEB. The error occurred in C:\CFusionMX7\wwwroot\PipeLine\Pipe_SchoolCoun\rm\reportMemberReg.cfm: line 31 29 : cfquery name=getReg datasource=#app.ds# timeout=120 30 :SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB, MEB.MembShpDate, ON ORD.UserID = MEB.MemberAutoID 31 :WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 32 :AND ORD.Deleted = 0 33 :AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') here is the full query. cfquery name=getReg datasource=#app.ds# timeout=120 SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB ON ORD.UserID = MEB.MemberAutoID WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 AND ORD.Deleted = 0 AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') ORDER BY MEB.MembShpDate DESC /cfquery ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250104 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Datediff help
The problem lies in the order that things are being executed. The DateDiff function is being processed by CF before it goes to the database. So CF is looking for a variable called MEB.MembShpDate and ORD.ProcessedDate not the database columns! You want to use the database function for dateDiff not CF's in this case. Not sure what database you are using but I think in SQLServer the function is called DateDiff. HTH Sam On 8/16/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have a query where I'm performing an inner join and the cfm page is telling me ... MembShpDate is an existiing column in the MemberDetails table and it's a valid datetime datatype. Any ideas? Full cfquery is after error message. The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request Element MEMBSHPDATE is undefined in MEB. The error occurred in C:\CFusionMX7\wwwroot\PipeLine\Pipe_SchoolCoun\rm\reportMemberReg.cfm: line 31 29 : cfquery name=getReg datasource=#app.ds# timeout=120 30 :SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB, MEB.MembShpDate, ON ORD.UserID = MEB.MemberAutoID 31 :WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 32 :AND ORD.Deleted = 0 33 :AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') here is the full query. cfquery name=getReg datasource=#app.ds# timeout=120 SELECT * FROM Orders ORD INNER JOIN MemberDetails MEB ON ORD.UserID = MEB.MemberAutoID WHERE #DateDiff ('d', MEB.MembShpDate, ORD.ProcessedDate)# = 0 AND ORD.Deleted = 0 AND (ORD.PaymentInfo = 'Membership Only' OR ORD.PaymentInfo = 'New Membership and Registration') ORDER BY MEB.MembShpDate DESC /cfquery ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250105 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
DateDiff bug?
I've been looking at how the DateDiff calculations work in CFMX 6.1 and found an odd issue. It appears that DateDiff thinks that 1942 only has 8759 hours and that 1945 has 8761 hours when both should have 8760. This code shows the discrepancy: CFLOOP FROM=1940 TO=1950 INDEX=y CFSET a = createDateTime(y-1,1,1,0,0,0) CFSET b = createDateTime(y ,1,1,0,0,0) CFSET d = dateDiff('h',a,b) BRCFOUTPUT#Year(a)# - #Year(b)# : #d#/CFOUTPUT /CFLOOP This weird hour counts appear in CFMX 6.1 and BlueDragon 6.2 but not in CF5. I'm guessing it may be a java issue? Is this a bug or a feature? :) Chris ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215456 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff bug?
I would imagine that's because the powers that be made some adjustment to time during those two years. Kind of like leap year, but a one-time deal. Since they're paired, it might be a change they made in 1942 (like turning on DST in the spring and not turning off in the fall), and then in 1945 decided that was silly, so they undid it (turned DST back off in the fall). That's just a WAG, but I'd imagine it's something along those lines, rather than a bug. cheers, barneyb On 8/17/05, Lofback, Chris [EMAIL PROTECTED] wrote: I've been looking at how the DateDiff calculations work in CFMX 6.1 and found an odd issue. It appears that DateDiff thinks that 1942 only has 8759 hours and that 1945 has 8761 hours when both should have 8760. This code shows the discrepancy: CFLOOP FROM=1940 TO=1950 INDEX=y CFSET a = createDateTime(y-1,1,1,0,0,0) CFSET b = createDateTime(y ,1,1,0,0,0) CFSET d = dateDiff('h',a,b) BRCFOUTPUT#Year(a)# - #Year(b)# : #d#/CFOUTPUT /CFLOOP This weird hour counts appear in CFMX 6.1 and BlueDragon 6.2 but not in CF5. I'm guessing it may be a java issue? Is this a bug or a feature? :) Chris -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215457 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff bug?
I thought it could've been something like that too. I tried Googling it a few different ways but couldn't find anything about it. But if that's the reason, why doesn't CF5 or JavaScript recognize it? It's just one of those things where an odd problem might crop up because of the consistency. Unlikely, I guess, but I'd still rather not have to worry about how dates are being handled... Chris -Original Message- From: Barney Boisvert Sent: Wednesday, August 17, 2005 2:36 PM To: CF-Talk Subject: Re: DateDiff bug? I would imagine that's because the powers that be made some adjustment to time during those two years. Kind of like leap year, but a one-time deal. Since they're paired, it might be a change they made in 1942 (like turning on DST in the spring and not turning off in the fall), and then in 1945 decided that was silly, so they undid it (turned DST back off in the fall). That's just a WAG, but I'd imagine it's something along those lines, rather than a bug. cheers, barneyb On 8/17/05, Lofback, Chris wrote: I've been looking at how the DateDiff calculations work in CFMX 6.1 and found an odd issue. It appears that DateDiff thinks that 1942 only has 8759 hours and that 1945 has 8761 hours when both should have 8760. This code shows the discrepancy: CFLOOP FROM=1940 TO=1950 INDEX=y CFSET a = createDateTime(y-1,1,1,0,0,0) CFSET b = createDateTime(y ,1,1,0,0,0) CFSET d = dateDiff('h',a,b) BRCFOUTPUT#Year(a)# - #Year(b)# : #d#/CFOUTPUT /CFLOOP This weird hour counts appear in CFMX 6.1 and BlueDragon 6.2 but not in CF5. I'm guessing it may be a java issue? Is this a bug or a feature? :) Chris -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215464 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff bug?
Here's an article I just found. Googled '1942 leap hour' and it was the first result: http://www.thesunchronicle.com/articles/2005/08/07/opinion/opinion5.txt cheers, barneyb On 8/17/05, Lofback, Chris [EMAIL PROTECTED] wrote: I thought it could've been something like that too. I tried Googling it a few different ways but couldn't find anything about it. But if that's the reason, why doesn't CF5 or JavaScript recognize it? It's just one of those things where an odd problem might crop up because of the consistency. Unlikely, I guess, but I'd still rather not have to worry about how dates are being handled... Chris -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215466 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff bug?
I tried everything BUT Leap Hour--who'd of thunk? So Java recognizes this, but not JS or CF5. Interesting... Chris -Original Message- From: Barney Boisvert Sent: Wednesday, August 17, 2005 3:17 PM To: CF-Talk Subject: Re: DateDiff bug? Here's an article I just found. Googled '1942 leap hour' and it was the first result: http://www.thesunchronicle.com/articles/2005/08/07/opinion/opi nion5.txt cheers, barneyb On 8/17/05, Lofback, Chris wrote: I thought it could've been something like that too. I tried Googling it a few different ways but couldn't find anything about it. But if that's the reason, why doesn't CF5 or JavaScript recognize it? It's just one of those things where an odd problem might crop up because of the consistency. Unlikely, I guess, but I'd still rather not have to worry about how dates are being handled... Chris -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215468 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff bug?
some adjustment to time during those two years. I'd really be surprised: the leap year system is so accurate that when an adjustment is necessary, it is only by a second, and after centuries only. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215470 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff bug?
Lofback, Chris wrote: I've been looking at how the DateDiff calculations work in CFMX 6.1 and found an odd issue. It appears that DateDiff thinks that 1942 only has 8759 hours and that 1945 has 8761 hours when both should have 8760. This code shows the discrepancy: depends on your timezone but that was during world war II everybody in the US was on DST even the bits like indiana which today aren't. it's a feature, you're asking for historical timezone data getting it. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215520 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff HUH???
Well, I did some experiments; I guess I am now using a patched version. So applying the updater is probably the best idea. cfoutput cfset startDate = parseDateTime(4/1/2005) cfset endDate = parseDateTime(4/5/2005) DateDiff(d,#startDate#,#endDate#) h1#DateDiff(d,startDate,endDate)#/h1 DateDiff(h,#startDate#,#endDate#) h1#DateDiff(h,startDate,endDate)#/h1 cfset startDate = parseDateTime(5/1/2005) cfset endDate = parseDateTime(5/5/2005) DateDiff(d,#startDate#,#endDate#) h1#DateDiff(d,startDate,endDate)#/h1 DateDiff(h,#startDate#,#endDate#) h1#DateDiff(h,startDate,endDate)#/h1 /cfoutput -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA C code. C code run. Run code run. Please! - Cynthia Dunning -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 4:02 PM To: CF-Talk Subject: Re: DateDiff HUH??? When using the d value of datediff, it is using 24 hours as a day. Since we lose an hour on 4/3/2005, you are one hour short of 9 days, and the extra 23 hours are truncated. Hmmm - OK, is there a good fix for this? Or does it require a previously mentioned updater? -- --- Les Mizzell ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198394 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff HUH???
http://dev.navtrak.net/dateDiffBug/anotherdatediffbug.cfm thats what i came up with just before red sky beta... tw On Fri, 11 Mar 2005 11:06:55 -0500, Les Mizzell [EMAIL PROTECTED] wrote: Ian Skinner wrote: Well, I did some experiments; I guess I am now using a patched version. So applying the updater is probably the best idea. Shared server - host that SUCKS - client that *likes* the host anyway. ACK!! Below is very close to what I came up with last night. Both work fine. Thanks to all that replied to this one. It was an interesting problem... cfoutput cfset startDate = parseDateTime(4/1/2005) cfset endDate = parseDateTime(4/5/2005) DateDiff(d,#startDate#,#endDate#) h1#DateDiff(d,startDate,endDate)#/h1 DateDiff(h,#startDate#,#endDate#) h1#DateDiff(h,startDate,endDate)#/h1 cfset startDate = parseDateTime(5/1/2005) cfset endDate = parseDateTime(5/5/2005) DateDiff(d,#startDate#,#endDate#) h1#DateDiff(d,startDate,endDate)#/h1 DateDiff(h,#startDate#,#endDate#) h1#DateDiff(h,startDate,endDate)#/h1 /cfoutput -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA C code. C code run. Run code run. Please! - Cynthia Dunning -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 4:02 PM To: CF-Talk Subject: Re: DateDiff HUH??? When using the d value of datediff, it is using 24 hours as a day. Since we lose an hour on 4/3/2005, you are one hour short of 9 days, and the extra 23 hours are truncated. Hmmm - OK, is there a good fix for this? Or does it require a previously mentioned updater? -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198416 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
DateDiff HUH???
What the hell? I've got a form that has select fields for year, month and day for return and depart trip dates. For the following: cfset dayAway = #DateDiff(D,#CreateDate(depYearSelect,depMonthSelect,depDaySelect)#,#CreateDate(retYearSelect,retMonthSelect,retDaySelect)#)# If the depart date is April 1st (2005,04,01) And the Return date is April 10th (2005,04,10) dayAway = 8 days! This is also true for: depart (2005,04,02) return (2005,04,11) depart (2005,04,03) return (2005,04,12) ***BUT*** depart (2005,04,04) return (2005,04,13) depart (2005,04,05) return (2005,04,14) depart (2005,04,06) return (2005,04,15) and up: dayAway = 9 days! This *ONLY* happens with APRIL as the month. depart (2005,06,01) return (2005,06,10) correctly returns the number 9. WTF?? Ideas? This *is * driving me crazy!! -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198276 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff HUH???
Are you running CFMX 6.x? This sounds like the daylight saving time bug that was fixed with an updater. DST changes at 2:00am on April 2 this year. Try a test of October when DST changes again. It would happen on the last Sunday in October. If that messes up, make sure you have the latest updaters for CFMX 6.x. M!ke -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 4:36 PM To: CF-Talk Subject: DateDiff HUH??? What the hell? I've got a form that has select fields for year, month and day for return and depart trip dates. For the following: cfset dayAway = #DateDiff(D,#CreateDate(depYearSelect,depMonthSelect,depDaySelect)#,#C reateDate(retYearSelect,retMonthSelect,retDaySelect)#)# If the depart date is April 1st (2005,04,01) And the Return date is April 10th (2005,04,10) dayAway = 8 days! This is also true for: depart (2005,04,02) return (2005,04,11) depart (2005,04,03) return (2005,04,12) ***BUT*** depart (2005,04,04) return (2005,04,13) depart (2005,04,05) return (2005,04,14) depart (2005,04,06) return (2005,04,15) .and up: dayAway = 9 days! This *ONLY* happens with APRIL as the month. depart (2005,06,01) return (2005,06,10) correctly returns the number 9. WTF?? Ideas? This *is * driving me crazy!! -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198280 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff HUH???
Day light savings is April 3rd. You would get the opposite results in October with any date range that spans 10/30/2005. When using the d value of datediff, it is using 24 hours as a day. Since we lose an hour on 4/3/2005, you are one hour short of 9 days, and the extra 23 hours are truncated. It may be hard to believe, but this is desired behavior when doing other kinds of date diff situations. -- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA C code. C code run. Run code run. Please! - Cynthia Dunning -Original Message- From: Les Mizzell [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 2:36 PM To: CF-Talk Subject: DateDiff HUH??? What the hell? I've got a form that has select fields for year, month and day for return and depart trip dates. For the following: cfset dayAway = #DateDiff(D,#CreateDate(depYearSelect,depMonthSelect,depDaySelect)#,#Cr eateDate(retYearSelect,retMonthSelect,retDaySelect)#)# If the depart date is April 1st (2005,04,01) And the Return date is April 10th (2005,04,10) dayAway = 8 days! This is also true for: depart (2005,04,02) return (2005,04,11) depart (2005,04,03) return (2005,04,12) ***BUT*** depart (2005,04,04) return (2005,04,13) depart (2005,04,05) return (2005,04,14) depart (2005,04,06) return (2005,04,15) and up: dayAway = 9 days! This *ONLY* happens with APRIL as the month. depart (2005,06,01) return (2005,06,10) correctly returns the number 9. WTF?? Ideas? This *is * driving me crazy!! -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198282 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: DateDiff HUH???
D'oh! I meant the 3rd. You know what I meant. ;^) M!ke -Original Message- From: Ian Skinner [mailto:[EMAIL PROTECTED] Sent: Thursday, March 10, 2005 4:54 PM To: CF-Talk Subject: RE: DateDiff HUH??? Day light savings is April 3rd. You would get the opposite results in October with any date range that spans 10/30/2005. When using the d value of datediff, it is using 24 hours as a day. Since we lose an hour on 4/3/2005, you are one hour short of 9 days, and the extra 23 hours are truncated. It may be hard to believe, but this is desired behavior when doing other kinds of date diff situations. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198297 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: DateDiff HUH???
When using the d value of datediff, it is using 24 hours as a day. Since we lose an hour on 4/3/2005, you are one hour short of 9 days, and the extra 23 hours are truncated. Hmmm - OK, is there a good fix for this? Or does it require a previously mentioned updater? -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:198306 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
datediff gotcha
Just a small tip. When doing a datediff in CF, make sure both values are actually dates. I just ran a datediff where the second value (the first date) came from a DB. The value was actually a blank and CFMX threw a variable does not exist null error. This was not expected as the variables all existed and the only difference was that the date value was not a date. CFIF datediff('d', qLastOrdered.lastdate, now()) LT 180 I solved this by adding a simple test to make sure that the value was a date: CFIF Not IsDate(qLastOrdered.lastdate) OR datediff('d', qLastOrdered.lastdate, now()) LT 180 ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192804 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: datediff gotcha
In the same vein - watch out for datediffs where the value is too big. CF will roll over the value if it goes over the maximum size of numbers in CF. This confused the heck out of me when I was building Death Clock (years and years and years ago). On Wed, 2 Feb 2005 15:42:03 -0500, Michael Dinowitz [EMAIL PROTECTED] wrote: Just a small tip. When doing a datediff in CF, make sure both values are actually dates. I just ran a datediff where the second value (the first date) came from a DB. The value was actually a blank and CFMX threw a variable does not exist null error. This was not expected as the variables all existed and the only difference was that the date value was not a date. CFIF datediff('d', qLastOrdered.lastdate, now()) LT 180 I solved this by adding a simple test to make sure that the value was a date: CFIF Not IsDate(qLastOrdered.lastdate) OR datediff('d', qLastOrdered.lastdate, now()) LT 180 ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192805 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: datediff gotcha
Ray, did you build _the_ Death Clock? The one that was all the rage from radio stations to net geeks about 7 years ago? I remember that thing At 03:54 PM 2/2/2005, you wrote: In the same vein - watch out for datediffs where the value is too big. CF will roll over the value if it goes over the maximum size of numbers in CF. This confused the heck out of me when I was building Death Clock (years and years and years ago). On Wed, 2 Feb 2005 15:42:03 -0500, Michael Dinowitz [EMAIL PROTECTED] wrote: Just a small tip. When doing a datediff in CF, make sure both values are actually dates. I just ran a datediff where the second value (the first date) came from a DB. The value was actually a blank and CFMX threw a variable does not exist null error. This was not expected as the variables all existed and the only difference was that the date value was not a date. CFIF datediff('d', qLastOrdered.lastdate, now()) LT 180 I solved this by adding a simple test to make sure that the value was a date: CFIF Not IsDate(qLastOrdered.lastdate) OR datediff('d', qLastOrdered.lastdate, now()) LT 180 ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192808 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: datediff gotcha
Do you have a relative idea what that value is? In the same vein - watch out for datediffs where the value is too big. CF will roll over the value if it goes over the maximum size of numbers in CF. This confused the heck out of me when I was building Death Clock (years and years and years ago). On Wed, 2 Feb 2005 15:42:03 -0500, Michael Dinowitz [EMAIL PROTECTED] wrote: Just a small tip. When doing a datediff in CF, make sure both values are actually dates. I just ran a datediff where the second value (the first date) came from a DB. The value was actually a blank and CFMX threw a variable does not exist null error. This was not expected as the variables all existed and the only difference was that the date value was not a date. CFIF datediff('d', qLastOrdered.lastdate, now()) LT 180 I solved this by adding a simple test to make sure that the value was a date: CFIF Not IsDate(qLastOrdered.lastdate) OR datediff('d', qLastOrdered.lastdate, now()) LT 180 ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192809 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: datediff gotcha
Yep...that was the JediMaster ;-) Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: [EMAIL PROTECTED] web: www.electricedgesystems.com ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192810 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54