something like this might be even easier to read .. some psuedo code (not
sure if the week function still exists in CFMX) ... test before running
function WeekOfMonth(inputDate) {
// Cache current weeks of the year (WoY)
iWoYStart = week(createdate(year(inputDate),month(inputDate),1))
iWoYCurrent = week(inputDate)
// Cache the difference which should be the week of the month (WoM) base
0
iWoM = iWoYCurrent - iWoYStart
// Return the week of the month (base 1)
return iWom + 1
}
----- Original Message -----
From: "Ben Bishop" <[EMAIL PROTECTED]>
Newsgroups: cfaussie
To: "CFAussie Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, February 15, 2003 4:08 AM
Subject: [cfaussie] Re: Week Of Month UDF
> Hi Steve,
>
> Nice to see you're working reasonable hours! Interesting UDF, thought I'd
> try the challenge:
>
> function WeekOfMonth(date) {
>
>
CurrentWeek=IncrementValue(DateDiff("ww",CreateDate(Year(date),Month(date),1
> ),DateAdd("d",8-DayofWeek(date),date)));
> return CurrentWeek;
> }
>
> It's a bit clearer when expanded:
>
> function WeekOfMonth(date) {
> // Get the first of month
> FirstofMonth=CreateDate(Year(date),Month(date),1);
> // Get the end of current week
> EndofWeek=DateAdd("d",8-DayofWeek(date),date);
> // Count the Sundays between the two
> CurrentWeek=IncrementValue(DateDiff("ww",FirstofMonth,EndofWeek));
> return CurrentWeek;
> }
>
> Cheers,
>
> Ben
>
>
> "Steve Onnis" <[EMAIL PROTECTED]> wrote in message
news:23171@cfaussie...
>
> > Am CERTAIN this one works properly:P
>
>
>
>
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to
[EMAIL PROTECTED]
>
> MX Downunder AsiaPac DevCon - http://mxdu.com/
>
---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MX Downunder AsiaPac DevCon - http://mxdu.com/