Here is the last 7 days values query without including their time ---
between convert(varchar(10),(getdate()-6),120) and convert(varchar(10),getdate(),120))
order by modified_date desc;
--------
report_mstr = table name
modified_date = datefield
select * from report_mstr
where (convert(varchar(10),modified_date,120) between convert(varchar(10),(getdate()-6),120) and convert(varchar(10),getdate(),120))
order by modified_date desc;
--------
select getdate();
->>>> 2012-07-11 15:41:31.547
select getdate()-6;
->>>> 2012-07-05 15:40:20.983
select convert(varchar(10),getdate(),120);
->>>> 2012-07-11
No comments:
Post a Comment