Hi anyone knows how to convert a string to a date variable in coldfusion? i have a string "200611" which is in yyyymm format andi wish to convert it into a date variable of yyyymm format thanks in advance ...
Hi youjie, you could try this. <!--- set the date string ---> <cfset input = "200611"> <!--- extract the first 4 characters from the string ---> <cfset yearpart = mid(input, 1,4)> <!--- extract the last 2 characters from the string ---> <cfset monthpart = mid(input, 5,2)> <!--- create a date using the two parts ---> <cfset date = createdate(yearpart, monthpart, 01)> <!--- output the date with the formatting ---> <cfoutput>#dateformat(date, 'yyyy/mm')#</cfoutput> Hope this helps