Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate no. of days in a month
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00313726
Message ID:
00313733
Vues:
26
Hi,
Try this:
* Program....: DOWINMONTH.PRG
* Version....: 1.0
* Author.....: Andrew Coates
* Date.......: January 6, 2000
* Notice.....: Copyright © 2000 Civil Solutions, All Rights Reserved.
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* Abstract...: Returns the number of a particular days in a month
* Requires...: The number of the day in question (see DOW() docs for numbering)
*   The month in question (1-12)
*   the year in question (to account for leap years)
* Changes....:

lParameters tnDayNumber, tnMonth, tnYear

local ldFirstDay, lnDOWFirstDay, ldLastDay, lnDOWLastDay, lnDaysInMonth

ldFirstDay = date(tnYear, tnMonth, 1)
ldLastDay = gomonth(ldFirstDay, 1) - 1
lnDOWFirstDay = DOW(ldFirstDay)
lnDOWLastDay = DOW(ldLastDay)

lnDaysInMonth = int(day(ldLastDay)/7) + ;
	iif(between(tnDayNumber + iif(tnDayNumber < lnDOWFirstDay, 7, 0), lnDOWFirstDay, lnDOWLastDay + iif(lnDOWLastDay < lnDOWFirstDay, 7, 0)), 1, 0)

return lnDaysInMonth
Cheers,

Andrew

>I need a function or 'select statemt' that can calculate the no. of distinct days in a month. For example, I would like the fn to calculate the total no of Sundays or any of the other 6 days in January. Preferably there is to be no keying of dates. Thanks in advance.


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform