Wednesday, December 14, 2011

Displaying current date last week date using sql server


declare @fromdate datetime;
declare @enddate datetime;
set @fromdate=(select convert(datetime, (convert (varchar(10), getdate(),101))))
set @enddate=(select convert(datetime, (convert (varchar(10), getdate()-2,101))))

select *from Votes where VotedOn between  @enddate and @fromdate

No comments:

Post a Comment