×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Microsoft: FoxPro FAQ

## Usefull Functions & Procedures

 Week Of Month, First Day & NextSunday functions by GriffMG faq184-4468 Posted: 21 Nov 03 (Edited 21 Nov 03) ** simple functions for WeekOfMonth** This bit helps you test it!clearset date britishm.date = date()do while lastkey() <> 27    @ 10,10 say "Date" get m.date    read    clear gets    @ 11,10 say FirstDay(m.date)    @ 12,10 say NextSunDay(FirstDay(m.date))    @ 13,10 say WeekOfMonth(m.date)enddo    ** this is the actual function function WeekOfMonth    parameter m.date    private m.date,i,m.factor    ** the week is...     ** first get the day of the first sunday in the month    ** by getting the first day, and then getting the next Sunday    ** after that    i = Day(NextSunDay(FirstDay(m.date)))    ** if the day isn't before that first sunday....    if Day(m.date) > i        if i > 1            m.factor = 2        else            m.factor = 1        endif        ** calculate the differnce between the days (of your date and the        ** first sunday) divide that by the number of days in a week        ** (taking just the integer bit) and add the week factor - because        ** the first week has been excluded by the if, and we want the        ** balance to start at 2 for weeks after that        i = int((Day(m.date)-i)/7)+m.factor    else        i = 1    endif    return(i)** this always gives you the first day of any monthfunction FirstDay    parameter m.date    private m.date    m.date = m.date - Day(m.date) + 1     return(m.date)    ** this returns the next Sunday...    function NextSunDay    parameter m.date    private m.date,i    i = 8 - dow(m.date)  && 1=Sunday    if i < 7        m.date = m.date + i    endif    return(m.date) Back to Microsoft: FoxPro FAQ Index Back to Microsoft: FoxPro Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!