"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Friday, November 30, 2012

select records from particular week days Or datepart in sql

select records from particular week days Or datepart in sql


SELECT AgencyId,CreatedOn FROM Agencies -- List All Records

SELECT AgencyId,CreatedOn FROM Agencies WHERE (datepart (dw, CreatedOn)) IN (7,1) -- List records Only on saturday and sunday

SELECT AgencyId,CreatedOn FROM Agencies WHERE (datepart (dw, CreatedOn)) NOT IN (5,2) -- List all Records EXCEPT Thuesday and Monday
 




If u had any trouble just ask, Happy to help u :) Stay Tune... Have a nice day... 'N happy Coding :)

No comments: