<!--- Set Date parameters used in the where clause of the query --->
<cfscript>
        firstOfMonth = CreateDate(year,month,1);
        endOfMonth = CreateDate(year,month,DaysInMonth(firstOfMonth));
        startday = 2; //1=Sunday, 2=Monday, ..., 7=Saturday
        
        //calculate first day of calendar display.
        daynum = DayOfWeek(firstOfMonth);
        if (daynum - (startday - 1) LT 1)
                offset = 7 + (daynum - (startday - 1));
        else
                offset = (daynum - (startday - 1));
                
        firstDay = DateAdd("d",-(offset-1),firstOfMonth);

        //calculate last day of calendar display
        daynum = DayOfWeek(endOfMonth);
        if (daynum - (startday - 1) LT 1)
                offset = -(daynum - (startday - 1));
        else
                offset = 7 - (daynum - (startday - 1));
                
        lastDay = DateAdd("d",offset,endOfMonth);
</cfscript>

Here is some code I use in a similar situation.  This will create output 
something like this:

29 30  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 29 30 31  1  2  3

If you don't want the dates from the previous and following months such as the 
example, I think you just need the offset values from my calculations.


--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

"C code. C code run. Run code run. Please!"
- Cynthia Dunning



Confidentiality Notice:  This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message. 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186856
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to