Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 19,024 of 19,505    |
|    Ross Presser to Andy    |
|    Re: Advanced DateDiff Calculation In SQL    |
|    03 Mar 14 13:38:41    |
      From: rpresser@gmail.com              On Monday, March 3, 2014 3:35:04 PM UTC-5, Andy wrote:       > Hi Everyone       >       > I have an odd question for SQL       >       > I'm trying to do a calculation on 2 date fields. I'd like to get       > the exact difference in time between 2 dates but I don't want to       > include any time if the duration falls over a weekend. For       > example, find me the difference in time with the following but       > don't include any time after Friday at midnight to Sunday at       > midnight.       >       > StartDate = 03/14/2014 12:09:00pm       > EndDate = 03/17/2014 09:24:00am       >       > Or even more seemingly complex...       >       > StartDate = 03/14/2014 12:09:00pm       > EndDate = 03/24/2014 09:24:00am              The standard solution to this problem is to make use of a calendar       table. This is a table with a DATE primary key, and assorted other       columns, such is IS_WEEKEND or IS_FEDERAL_HOLIDAY. Such a table       occupies little space compared to real data, can be generated very       quickly, and makes complex date computations very simple.              http://stackoverflow.com/questions/5635594/how-to-create-a-calen       er-table-for-100-years-in-sql              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca