"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 value="2">
      <cfset monthvar = "02">
   <cfcase value="3">
      <cfset monthvar = "03">
   <cfcase value="4">
      <cfset monthvar = "04">
   <cfcase value="5">
      <cfset monthvar = "05">
   <cfcase value="6">
      <cfset monthvar = "06">
    <cfcase value="7">
      <cfset monthvar = "07">
   <cfcase value="8">
      <cfset monthvar = "08">
   <cfcase value="9">
      <cfset monthvar = "09">
   <cfcase value="10">
      <cfset monthvar = "10">
   <cfcase value="11">
      <cfset monthvar = "11">
   <cfcase value="12">
      <cfset monthvar = "December">

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!