change month number to name

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default change month number to name

    I have a setting for a calendar that defaults the calender to the current month
    <cfset cal_month=dateformat(now(), "m")>
    This can be changed by the user to any month
    When the month is displayed I want to show the name of the month instead of
    the number, i.e. if cal_month is 1 I want it to display January.

    I tried #dateformat(month(cal_month), "mmmm")# but it came back as december
    everytime
    I placed a #cal_month# next to it to make sure the month wasn't defaulting
    somehow to 12 but it was still set as 1

    thanks

    sattman Guest

  2. Similar Questions and Discussions

    1. Change the first number
      Hi All, I have a list of ID numbers that are populated in from a query into a cfselect. The numbers start a 1, but 1 is a fixed field that will...
    2. Getting the month by Number
      Hi Folks, I'm trying to create an archive system, and want to be able to display articles according to the month. The system I have setup at the...
    3. Current month change
      Hello, Total n00b here who needs help. I have a list of weblog (blog) entries in a database which are being retrieved by index.php with a string...
    4. Can I change view from month to week in calendar control ?????
      I want to make a week view and day view just like month view calendar control in .NET. if any one knows how to do that or any one has the source...
    5. Can I display a month from a number in a csv file?
      Greetings from a second day newbie to php. I think I have figured out a way to explode a field in a csv file (like 11-08-03) and implode it as...
  3. #2

    Default Re: change month number to name

    That would be the MonthAsString function.
    Dan Bracuk Guest

  4. #3

    Default Re: change month number to name

    sattman,

    Just for future reference. You don't need to use the month() function on
    #cal_month# because you have already set it to a month number in this statement.

    <cfset cal_month=dateformat(now(), "m")>

    Dateformat() requires a valid date object (eg. date in format mm/dd/yyyy).
    Here you are passing in a month number which is why it is returning the wrong
    results.

    #dateformat(month(cal_month), "mmmm")#

    That said, use #MonthAsString(monthNumber)# instead.

    mxstu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139