You can do this:

<cfset pubDate = Mid(FileName,4,6)>
returns '122906'

<cfset temp1 = insert('-',pubdate,2)>
<cfset temp2 = insert('-',temp1,5)>
This will give you '12-29-06'

Then
<cfset mydateobj = parsedatetime(temp2)>

-- Josh



----- Original Message ----- 
From: "Crow T. Robot" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Friday, June 15, 2007 9:18 AM
Subject: Re: converting a string to a date - most efficient way?


> Yea, my first attempt was something similar:
>
> CreateDate(Left(pubDate,2),Mid(pubDate,3,2),Right(pubDate,2))
>
> but it throws errors (unspecified ones at that)
>
> So does this, weirdly enough:
>
> <cfset FileName = "01-122906WASH-CIRC.txt">
>
> <cfset pubDate = Mid(FileName,4,6)>
>
> <cfset month = Left(pubDate,2)>
> <cfset day = Mid(pubDate,3,2)>
> <cfset year = Right(pubDate,2)>
>
>
>
> <cfset pubDate = CreateDate(month,day,year)>
>
> <cfoutput>#month#/#day#/#year# - #pubDate#</cfoutput>
>
>
>
> On 6/15/07, Adkins, Randy <[EMAIL PROTECTED]> wrote:
>>
>> May not be the most efficient way but:
>>
>> CreateDate(MID(myString,5,2), MID(myString,3,2), MID(myString,1,2))
>>
>>
>> -----Original Message-----
>> From: Ray Champagne [mailto:[EMAIL PROTECTED]
>> Sent: Friday, June 15, 2007 12:05 PM
>> To: CF-Talk
>> Subject: converting a string to a date - most efficient way?
>>
>> So, I have a file that I am uploading that contains a string that
>> represents the date, and I need to extract the date from the filename.
>> I have the extraction down to a string that looks like MMDDYY (ex:
>> 120507) and I need to turn that into an ODBC date in the most efficient
>> way possible.
>>
>>
>>
>> I've got a few ideas, but they all basically suck.  Any takers?
>>
>>
>>
>> --
>>
>> Ray Champagne
>>
>> Web Developer, Dolan Media Company
>>
>> 612.215.6497 :: 612.718.8852 (m)
>>
>> ray.champagne [at] dolanmedia [dot] com
>>
>> GTalk: raychampagne
>>
>>
>>
>>
>>
>>
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281304
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to