"Our customers were reporting a strange bug," Eric writes, "when they would select dates for events in December, they'd get the following message."

Conversion failed when converting datetime from character string 'De/09/2010'

Eric continues, "actually, it wasn't that strange of a bug, considering that the event module was written by a certain developer on our team. When I dug through the code, I found the culprit."

<cfswitch expression="#month#">
   <cfcase value="1">
      <cfset monthvar = "01">
   </cfcase>
   <cfcase value="2">
      <cfset monthvar = "02">
   </cfcase>
   <cfcase value="3">
      <cfset monthvar = "03">
   </cfcase>
   <cfcase value="4">
      <cfset monthvar = "04">
   </cfcase>
   <cfcase value="5">
      <cfset monthvar = "05">
   </cfcase>
   <cfcase value="6">
      <cfset monthvar = "06">
   </cfcase>   
    <cfcase value="7">
      <cfset monthvar = "07">
   </cfcase>
   <cfcase value="8">
      <cfset monthvar = "08">
   </cfcase>
   <cfcase value="9">
      <cfset monthvar = "09">
   </cfcase>
   <cfcase value="10">
      <cfset monthvar = "10">
   </cfcase>
   <cfcase value="11">
      <cfset monthvar = "11">
   </cfcase>
   <cfcase value="12">
      <cfset monthvar = "December">
   </cfcase>

Eric continues, "it would appear that, for this developer, it's easier to run your date value through a 12-case switch statement instead of using the DateFormat(). I was also happy to learn that the two digit representation of December isn't '12', but 'December'."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!