I am coding for a software and m stuck at a place where i need to count the number of working days in a week tht is excluding sundays. I am using Visual Basic 6.0 (not vb.net). Can anyone please guide me with the functions by which i can get it done..... ??? Thanx...
Related to coding in VB?? Excluding sundays in counting the days of a month. (Counting business days only)?
There's a function called weekday. You pass it a date and it returns a number from 1 to 7 indicating what weekday it is. I'm not sure, but I believe it says 1 is Sunday (make sure of this with your localization - plug in sunday's date and see what number it returns).
Then you can do:
dim i as integer
dim cnt as integer
i = 0
dt = "01/01/2007"
for cnt = 1 to 31
if weekday(dt)%26lt;%26gt;1 then i = i + 1
dt = dateadd(day,1,dt) 'not sure about the syntax, but it's something like that
next cnt
msgbox "there were " %26amp; i %26amp; " working days in january."
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment