Wednesday, March 21, 2012

How to create a view to search records between 1pm yesterday and 7

How to create view to search records between 1:00pm yesterday an 7:00am toda
y?Why do you need a view to do that? I assume this is the WHERE clause you are
looking for?
SELECT * FROM YourTableOrView
WHERE YourDT >=
CONVERT(DATETIME,CONVERT(CHAR(8),DATEADD
(dd,-1,GETDATE()),112) + ' ' +
'13:00:00')
AND YourDT < CONVERT(DATETIME,CONVERT(CHAR(8),GETDATE
(),112) + ' ' +
'07:00:00')
Andrew J. Kelly SQL MVP
"View" <View@.discussions.microsoft.com> wrote in message
news:AD50EE4D-9335-4831-8738-C700712C28FF@.microsoft.com...
> How to create view to search records between 1:00pm yesterday an 7:00am
> today?

No comments:

Post a Comment