|
-
Mar 30th, 2000, 07:27 PM
#1
Thread Starter
Junior Member
Does anyone know how to use the DateDiff function to return the number of workdays (M-F) between two dates in SQLServer. Or is there any other function you can use. Can you write your own functions to use in views? If anyone has any ideas I would appreciate your comments.
Thanks
-
Mar 31st, 2000, 02:50 AM
#2
Frenzied Member
Select DATEDIFF(day,datefield1,datefield2) will get you the number of days
Select DATEDIFF(week,datefield1,datefield2) will get you the number of weeks
You might be able to do something like, but it won't be precise.
declare @numWrkDays Int
declare @numDays Int
declare @numWeeks int
Select @numDays = DATEDIFF(day,datefield1,datefield2)
Select @numWeeks=(DATEDIFF(week ,datefield1,datefield2)
Select @numWrkdays = @numdays - (@numweeks *2)
To answer your other questions, you could write an extended procedure in C/C++ that could be called from a script (if one doesn't already exist).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|