Subtracting end date  inital date but count only week days not Saturdays and Sundays
Hi,
Is possible to subtract the end date  start date and get the number of days but without weekends? So, if I am on Friday and my end date is the following Monday then I should get 1 instead of 3. <root> <StartDate>9 July 2012</StartDate> <StartDate>24 September 2016</StartDate> <root> Cheers C asdfasdf 
First write a function to compute day of week dow() for a given date: subtract a wellknown Sunday from the date, divide by the duration PT1D, then take the result modulo 7.
Now subtract the two dates, divide by the duration PT1D to get an integer number of days D, and then take W= (D div 7)*5 to get the number of weekdays in whole weeks. Then work out how many extra days you need to add based on the dayofweek of the two days: if you know that both are weekdays, this is dow(END)dow(START) if positive, otherwise 7(dow(START)dow(END)). 
Hi Michael,
Thanks very much for your reply. I am trying to learn now to do this in XSLT 1.0. I know your explanation was very thorough. Could you please kindly show us how to create this method. I really would like to learn how to do this but I guess I am not a guru like you guys (i.e. not as clever as you guys). Cheers C 
Sorry, it's years since I've written any XSLT 1.0 code, thank goodness. If you're really unable to move to 2.0, you'll have to look at what the EXSLT dateandtime library offers (assuming its available to you). If it's not available, you'll have to drop into some other language.

Thanks for letting me know it is not possible to achieve this in version 1 for it is too hard.

All times are GMT 4. The time now is 12:03 PM. 
Powered by vBulletin®
Copyright ©2000  2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.