Reputation: 1079
I am using the following stuff to for data conversion:
<cfset Year = Left(mbTimeStamp_dt,4)>
<cfset Month = mid(mbTimeStamp_dt,5,2)>
<cfset Date = mid(mbTimeStamp_dt,7,2)>
<cfset Hour = mid(mbTimeStamp_dt,9,2)>
<cfset Minute = right(mbTimeStamp_dt,2)>
<cfset NewDate= "#Createdatetime(Year,Month,Date,Hour,Minute,00)#">
<cfset PSTTime = #DateConvert("UTC2Local", NewDate )# >
<cfset ESTTime = DateAdd('h',3,PSTTime)>
But I am getting an error on the following line:
<cfset NewDate= "#Createdatetime(Year,Month,Date,Hour,Minute,00)#">
Error message: "The value 1- cannot be converted to a number. "
Am I doing something wrong? For your reference, my mbTimestamp_dt
value looks like this:
2013-06-06 11:51:37
Upvotes: 0
Views: 912
Reputation: 317
All your string parsing functions, save for year, are returning incorrect values. As others have said, output those values before trying to do anything with them and you'll see what's wrong.
On a side note. Rather than parsing the string manually, you could use some of the built in ColdFusion date/time functions to fetch your relevant values.
<cfset Year = Year(mbTimeStamp_dt)>
<cfset Month = Month(mbTimeStamp_dt)>
<cfset Day = Day(mbTimeStamp_dt)>
<cfset Hour = Hour(mbTimeStamp_dt)>
<cfset Minute = Minute(mbTimeStamp_dt)>
<cfset NewDate = createDateTime(Year, Month, Day, Hour, Minute, 00)>
<cfset PSTTime = dateConvert("UTC2Local", NewDate)>
<cfset ESTTime = dateAdd('h', 3, PSTTime)>
I changed your variable Date
to Day
to avoid ambiguity.
Hope that helps.
Upvotes: 5
Reputation: 20804
Output every one of those variables. The one with a hyphen in it is the one causing the problem. Then look at your string functions.
Make sure you test the month, date, hour, and minute functions with timestamps that give both 1 and 2 digit numbers.
Edit
Not related to your question, but you are assigning the seconds from your timestamp string to the Minute variable.
Upvotes: 0