[email protected] wrote:
> Given a week number, what function should I use to determine the range
of dates of that particular week?
>
> Example:  today is Sep 15th, 2009
>
> week( date()) = 38
>
> Now, if I know the week number (week 38), how can I tell the first and
last days of that week?
>
> Is there a specific function in VFP or should I build my own?


Ed Leafe had some common functions to provide this kind of stuff.
Here's what I have from long ago:

        FUNCTION FirstDayOfMonth(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (tdDate - (DAY(tdDate)-1))
        ENDFUNC && FirstDayOfMonth


        FUNCTION LastDayOfMonth(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (GOMONTH(tdDate,1) - DAY(GOMONTH(tdDate,1)))
        ENDFUNC && LastDayOfMonth


        FUNCTION FirstDayOfWeek(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (tdDate - (DOW(tdDate)-1))
        ENDFUNC && FirstDayOfWeek


        FUNCTION LastDayOfWeek(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (tdDate + (7 - DOW(tdDate)))
        ENDFUNC && LastDayOfWeek


        FUNCTION LastMonthDate(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (GOMONTH(tdDate,-1))
        ENDFUNC && LastDayOfWeek


        FUNCTION NextMonthDate(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (GOMONTH(tdDate,1))
        ENDFUNC && LastDayOfWeek


        FUNCTION JulianDate(tdDate as Date) as Date

                if PARAMETERS()=0 then
                        tdDate = date()
                endif

                return (tdDate - DATE(YEAR(tdDate)-1, 12, 31))
        ENDFUNC && JulianDate


-- 
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
http://fabmate.com
http://twitter.com/mbabcock16





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to