August 12, 2011 at 7:47 pm
Ask for a redesign to merge the 2 columns. This makes no sense and will always cause you problems down the road.
August 12, 2011 at 8:39 pm
doug 40899 (8/12/2011)
Actually ... in going back through my code, I realized I missed something. The time and date for this process is stored in two fields. Start time and start date. Both of which are timestamp values. So I think that I'll have to do a datepart for both portions of the query in the Where clause.DATEADD(MINUTE, mOnCallAdd.StartOnCallTime,
DATEADD(DAY, mOnCallAdd.StartOnCallDate, '12/31/1899'))
that query gives me a start time and date.
DATEADD(MINUTE, mOnCallDelete.duration,
DATEADD(MINUTE, mOnCallDelete.StartOnCallTime,
DATEADD(DAY, mOnCallDelete.StartOnCallDate, '12/31/1899')))
that gives me an end time. So my query will have to be against both those portions to make sure that it's not after the getdate. Any suggestions on how to do that?
I agree with Remi... having date and time in separate columns is a real killer. There's no chance of using an index properly to do the datetime lookups you want because you have to add the two columns together to do it right.
If you can't change those two columns, ask if you can add an indexed calculated column and then we can get on with the problem correctly.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 31 through 31 (of 31 total)
You must be logged in to reply to this topic. Login to reply