Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Working days between 2 dates
Message
De
25/02/2007 12:00:51
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01198129
Message ID:
01198631
Vues:
7
>Thanks Glenn... but I think I will just count the weekdays. Since some holidays move each year and are not just a specific date. This is not something that is a big deal.

I suggest a holiday table and a holiday function that can return all holidays between two dates with an optional parameter to tell it to exclude holidays that fall on weekends.

That way it can be combined with the working days function

?weekdays(date1,date2) - holidays(date1,date2,m.llExcludeWeekends)

and used on its own.


>
>>Hi Wayne,
>>
>>Here is some code which will count holidays between two dates.
>>
>>
>>TEXT
>>    * New Year's Day, January 1st.
>>    * Birthday of Martin Luther King, third Monday in January.
>>    * Inauguration Day, January 20th every four years, starting in 1937.
>>    * Washington's Birthday, third Monday in February since 1971; prior to that year, it was celebrated on the traditional date of February 22.
>>    * Inauguration Day, March 4th every four years, pre-1937.
>>    * Armed Forces Day, third Saturday in May.
>>    * Memorial Day, last Monday in May since 1971; from 1868 to 1970 it was celebrated on May 30, and was called Decoration Day for part of that time.
>>    * Flag Day, June 14th.
>>    * United States of America's Independence Day, July 4.
>>    * Labor Day, first Monday in September.
>>    * Columbus Day, second Monday in October (federal holiday since 1971).
>>    * Election Day, Tuesday on or after November 2.
>>    * Veterans Day, November 11th (except from 1971 to 1977, inclusive, when it was celebrated on the fourth Monday in October; formerly known as Armistice).
>>    * Thanksgiving Day, fourth Thursday in November.
>>    * Christmas Day, December 25th. I have finally included this since it is a federal holiday, although it is not based on a secular holiday.
>>Endtext
>>
>>CREATE TABLE holidays (Dayn n3, cHoliday c(20))
>>INSERT INTO holidays VALUES (1,'New Year')
>>INSERT INTO holidays VALUES (DOY({^2007/1/18}),'MLK Birthday')
>>INSERT INTO holidays values(DOY({^2007/2/19}),'Pres. Day')
>>*...
>>
>>SELECT COUNT(*) as Daysoff FROM Holidays ;
>>	WHERE Dayn between doy(nStartRange) and doy(nendrange)
>>
>>
>>FUNCTION DOY
>>LPARAMETERS tDate
>>RETURN VAL(SYS(11,tDATE)) - VAL(SYS(11,"12/31/"+STR(YEAR(tdate)-1)))
>>
>>
>>
>>Glenn
>>
>>>Thanks Tracy... that's kind of what I wrote. Do you know of one that will take into consideration holidays?
>>>
>>>
>>>>Counting weekdays between two dates Thread #915620 Message #915620
>>>>
>>>>>Does anyone have a function to get the number of working days between 2 dates? I'm working on a simple one, but thought someone might have one.
>>>>>
>>>>>TIA!!!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform