|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Quote:
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
good info, i'll take that into consideration.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Same code - Different Values? Why? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|