Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Count months between two dates
Message
From
08/08/2008 11:29:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01337391
Message ID:
01337540
Views:
14
>You have two dates, say 12-31-2007 and 03-01-2008. How can I count how months there are from 1st date to 2nd date. The answer I'm looking for is 4 (Dec 07, Jan 08, Feb 08, and Mar 08) - (Given the days maybe 28,29,30,or 31)
Procedure cntmonths(ts,te)
  Local lnMonths, ix, ldNext
  lnMonths = 0
  For ix=0 To m.te-m.ts
    lnMonths = m.lnMonths + 1
    ldNext = Gomonth(ts,m.ix)
    If Year(m.ldNext) = Year(m.te) And Month(m.ldNext) = Month(m.te)
      Exit
    Endif
  Endfor
  Return m.lnMonths
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform