Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating deadline from business hours
Message
De
24/01/2003 13:41:18
John Deupree
Long Term Care Authority
Tulsa, Oklahoma, États-Unis
 
 
À
24/01/2003 12:32:19
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00745070
Message ID:
00745184
Vues:
26
Mike,

Thanks for the reply.

There were a couple dealing with skipping weekends and holidays, but they started with a begin and end date and excluded days between.

I've tried converting the begin date to float to use in calculations, but found that it is not accurate enough.
set @BegDate = '01/15/2003 11:00:00'
set @fBegDate = cast(@BegDate as float)     -- returns 37634.5
print cast(@fbegdate as datetime)           -- returns '01/15/2003 11:00:00'

-- add 1 minute - still returns 11:00
set @BegDate = '01/15/2003 11:01:00'
set @fBegDate = cast(@BegDate as float)     -- returns 37634.5
print cast(@fbegdate as datetime)           -- returns '01/15/2003 11:00:00'
I have a routine that adds days to a date, excluding weekends and holidays. I can figure the # of days to add (add 40 hours = 4 - 9 hour business days with 4 hours left). It just gets sticky when I run into the next day. I then have to check for weekend or holidays again.

John

>I'm seem to remember seeing something like this in a pervious issue of SQL Mag.
>
>-Mike
>
>>I need to be able to calculate a deadline that is x hours from an input datetime. The calculation has to count only business hours (i.e. 8:00 AM to 5:00 PM) and exclude weekends and holidays. For example, if I have a 4 hour deadline, beginning at 3:00 PM on Monday, the deadline should be at 10:00 AM Tuesday. Likewise a 4 hour deadline at 3:00 PM Friday would be due at 10:00 AM Monday. I have UDF's that determine if a day is a weekend or holiday.
>>
>>TIA
>>
>>John
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform