ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 3rd, 2005, 06:21 PM
jonnycat jonnycat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 5 jonnycat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 35 m 45 sec
Reputation Power: 0
Question Same code - Different Values? Why?

I use this code...

<cfset #YEARADD# = #Year(Now())#-1900>
<cfset #FIRSTOFTHISMONTH# = #dateformat(DATEADD("yyyy", Val(YEARADD), CREATEODBCDATE(FIRSTDAYOFMONTH(NOW())+1)),'d')#>
<cfset #FIRSTOFNEXTMONTH# = #dateformat(DATEADD("yyyy", Val(YEARADD), CREATEODBCDATE(FIRSTDAYOFMONTH(NOW())+DAYSINMONTH(NOW()))),'d mmm yy')#>

exactly the same code on 2 seperate pages and I get different values on each page. On 1 page i get what I am looking for...

{ts '2005-02-01 00:00:00'} AND {ts '2005-03-01 00:00:00'}

On the second page I get...

{ts '2005-01-31 00:00:00'} AND {ts '2005-02-28 00:00:00'}

They are on the same server. Anyone know why these dont work the same?

Jon

Reply With Quote
  #2  
Old February 3rd, 2005, 06:32 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
No idea, I would try outputting various parts of all of that (yearadd, now(), the dateAdd() calls, etc.) to determine which one is actually different.

By the way, you can get rid of all of those pound signs. You only need to use pound signs when you are outputting something to the buffer or when you are evaluating an expression.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old February 3rd, 2005, 10:24 PM
jonnycat jonnycat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 5 jonnycat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 35 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
No idea, I would try outputting various parts of all of that (yearadd, now(), the dateAdd() calls, etc.) to determine which one is actually different.

By the way, you can get rid of all of those pound signs. You only need to use pound signs when you are outputting something to the buffer or when you are evaluating an expression.

I tried doing all the values seperate.. The only inconsistancy is in the CreateODBCDate(32) function. 32 being the FirstDayOfMonth(Now()). I tried everythig sererately and outputted them into fields on both pages.

The CreateODBCDate(32) on one page makes {ts '1900-02-01 00:00:00'}

while the other page makes {ts '1900-01-31 00:00:00'}.

The Next Month just adds 28 days to the first date.

I just dont inderstand how the same function of this can make two different dates from the same value on the same server. Maybe there is no answer.

Oh, when I first started writing in cold fusion, i always used the # signs. I just never got out of it I guess. Doesnt hurt my code though.

Jon

Reply With Quote
  #4  
Old February 3rd, 2005, 10:51 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
The pound signs make things much more difficult to read, and also increase execution time slightly as CF assumes that each one is an attempt to process an expression instead of a standard variable name.

I'm cetain that if you were simply outputting a createODBCDate on the *same* date on two pages you would get the same answer. I would guess that the fact that you are adding to or changing the date involved must be the cause of the difference in some way.

Reply With Quote
  #5  
Old February 4th, 2005, 08:14 PM
VelvettFogg VelvettFogg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 34 VelvettFogg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 13 m 46 sec
Reputation Power: 4
I'd remove the pound signs on the left side of the equal signs for sure.... And.. I disagree with the statement .. "Doesnt hurt my code though" .. you *are* taking a preformance hit.

Reply With Quote
  #6  
Old February 4th, 2005, 08:24 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
It's also just bad practice. I can promise you that if you sent that code in as example code for a job interview, a knowledgable ColdFusion developer would certainly note the unnecessary pound signs and it *would* affect their decision.

Reply With Quote
  #7  
Old February 8th, 2005, 04:56 PM
jonnycat jonnycat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 5 jonnycat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 35 m 45 sec
Reputation Power: 0
good info, i'll take that into consideration.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Same code - Different Values? Why?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT