Tested, seems to work okay. I'm baing this off of the Now() function,
but you can substitute any Date object, and the code should work the
same.
<cfparam name="SomeDate" default="#Now()#">
<cfparam name="MonthStart" default="#DateAdd("m",-1,SomeDate)#">
<cfparam name="MonthEnd" default="#DateAdd("m",-1,SomeDate)#">
<cfparam name="NumDays"
default="#DaysInMonth(DateAdd("m",-1,SomeDate))#">
<cfset MonthEnd =
#DateAdd("d",(DaysInMonth(MonthEnd)-Day(MonthEnd)),MonthEnd)#>
<cfset MonthStart = #DateAdd("d",(1-Day(MonthStart)),MonthStart)#>
<cfoutput>#DateFormat(MonthEnd,"mm/dd/yyyy")#</cfoutput>
<cfoutput>#DateFormat(MonthStart,"mm/dd/yyyy")#</cfoutput>
Matt Osbun
Web Developer
Health Systems, International
-----Original Message-----
From: Torrent Girl [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 19, 2005 12:51 AM
To: CF-Newbie
Subject: Re: HELP (ASAP!!)
I am not getting it.
I need an actual date.
I need to calculate and output the first and last date of the previous
month for any given month. In date format, not number of days.
This - #DaysInMonth(now())# returns the # of days (31)
and this #01/#Month(now())#/#Year(Now())# gives me an error.
On 5/19/05, Andrew Scott <[EMAIL PROTECTED]> wrote:
> Its actually very easy
>
> #DaysInMonth(now())# will return the number of days in the month.
>
> The first day is even easy, its always 1!!
>
> So you can do #01/#Month(now())#/#Year(Now())#
>
>
>
>
>
> Regards
> Andrew Scott
> Technical Consultant
>
> NuSphere Pty Ltd
> Level 2/33 Bank Street
> South Melbourne, Victoria, 3205
>
> Phone: 03 9686 0485 - Fax: 03 9699 7976
>
> -----Original Message-----
> From: Torrent Girl [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 19 May 2005 3:13 PM
> To: CF-Newbie
> Subject: HELP (ASAP!!)
>
> Can anyone please give me an example of how to calculate the first and
> last day of the previous month in CF?
>
> TGirl
>
>
> P.S. Please include examples (with syntax)
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:15:981
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54