SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    978
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird error with createDate

    Code CFM:
    <cfloop from="01" to="12" index="month">
    	<cfset start_date = CreateDate(Year(Now()), month, 1)>
    	<cfset end_date = CreateDate(Year(Now()), month, DaysInMonth(month))>
    	<cfoutput>
    		#start_date# | #end_date#<br/>
    	</cfoutput>
    </cfloop>

    So there's my code, I'm just trying to loop over the months of the year. When it gets to february (or '2') it throws an error only labeled 'month'.

    Any ideas?
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    make change as indicated in red --
    Code:
    <cfloop from="01" to="12" index="month">
        <cfset start_date = CreateDate(Year(Now()), month, 1)>
        <cfset end_date = CreateDate(Year(Now()), month, DaysInMonth(start_date))>
        <cfoutput>
            #start_date# | #end_date#<br/>
        </cfoutput>
    </cfloop>
    the DaysInMonth function requires a date as its parameter, not a month number

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    978
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.
    your brain reacts in the same way whether you are
    looking at something or thinking about it...


Bookmarks

Posting Permissions

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