Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    2

    Unanswered: Number of working days

    Hi,

    I am working on a Sybase database where I only have read permissions. I have to calculate the total number of business days (excluding saturdays and sundays) between two dates. As I cannot make temp tables or stored procedures, I have to use only the SQL queries. Can anyone please help me.

    Thanks,
    Meenu

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    Can't you just do a
    5 * datediff(week, @startdate,@enddate)

    This does not take into account any public holidays

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Assuming you work with all dates that exclude weekends
    Code:
    1> declare @strt1 datetime, @end1 datetime, @end2 datetime
    2> set @strt1='20051202', @end1='20051205', @end2='20051215'
    3> select 
    4>  diff1=datediff(day,@strt1,@end1)-2*datediff(week,@strt1,@end1)
    5> ,diff2=datediff(day,@strt1,@end2)-2*datediff(week,@strt1,@end2)
    6> go
    (1 row affected)
     diff1       diff2       
     ----------- ----------- 
               1           9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •