By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

date calculation

P: 15
plz help me ,to find week end dates between two dates.


for example,i selected two dates as starting and ending date in a textbox,from these in between dates i need to calculate every week end dates.

thanx
with regards
senthil
Nov 27 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 390
something like this may help you

Expand|Select|Wrap|Line Numbers
  1. Function f(ByVal FirstDate As Date,ByVal SecondDate As Date) As Long
  2. Dim StartDate As Date
  3. Dim EndDate As Date
  4. 'Place the dates in ascending order
  5. If FirstDate > SecondDate Then
  6. StartDate = SecondDate
  7. EndDate = FirstDate
  8. Else
  9. StartDate = FirstDate
  10. EndDate = SecondDate
  11. End If
  12.  
  13. 'How many FULL weeks are there within the date range
  14. NumWeeks = (EndDate - StartDate) \ 7
  15.  
  16. 'There are two non-working days in each full week
  17. NowWorkingDaysBetween = NumWeeks * 2
  18.  
  19. 'Add the number of non-working days in the remaining partial week
  20. For d = (StartDate + NumWeeks * 7) To EndDate
  21. If (Weekday(d) Mod 6) = 1 Then
  22. NowWorkingDaysBetween = NowWorkingDaysBetween + 1
  23. End If
  24. Next
  25.  
  26. End Function
Nov 27 '07 #2

acoder
Expert Mod 15k+
P: 16,027
Please use code tags when posting code.

Your VB code now needs to be adapted to JavaScript. It shouldn't be too difficult using the Date object.
Nov 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.