×
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

 Return the first or last day of the month by StewartUK faq184-3683 Posted: 4 Jun 03 This was developed from Thread184-566780 with thanks to Andrew Coates for the syntax for the last day of the month.Obviously myDate is a variable of type DATE. You could replace this with the VFP DATE() for the current date.You could easily put these into a function feeding in mydate and constants (say 1 to get the first day & 31 to get the last day) to determine whether the function returns the first day of the month or the last day. You could have a third parameter for stating whether to return dates for the previous, current or next month say -1, 0 & 1.I've tested these functions with first, middle & last dates of the next 12 months (which includes a leap-year) and they seemed to return the correct results in every case.For the first day of the previous month GOMONTH(GOMONTH(myDate, IIF(DAY(mydate)=1,1,0)) - DAY(GOMONTH(myDate, IIF(DAY(mydate)=1,1,0))-1),-1)For the last day of the previous month GOMONTH(myDate, 0) - DAY(GOMONTH(myDate, 0))For the first day of the current month GOMONTH(myDate, IIF(DAY(mydate)=1,1,0)) - DAY(GOMONTH(myDate, IIF(DAY(mydate)=1,1,0))-1)For the last day of the current month GOMONTH(myDate, 1) - DAY(GOMONTH(myDate, 1))For the first day of the next month GOMONTH(GOMONTH(myDate, IIF(DAY(mydate)=1,1,0)) - DAY(GOMONTH(myDate, IIF(DAY(mydate)=1,1,0))-1),1)For the last day of the next month GOMONTH(mydate,2)-DAY(GOMONTH(mydate,2)) 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!