sql - Submit Date After 7 -


i have table in there 2 columns date status

create table status (     date nvarchar(20),     status bit ) 

now want select records status = false , date after 7 days of submit, if today have insert 2 records false status want query show record after 7 day on 8-04-2015 records of 1-04-2015 status false should show.

if understand question; please tell do.

as @gvee stated in comment above, should store dates either date or datetime field. allow query so:

select [date], [status] <yourtable> [date] <= dateadd(d, -7, getdate()) , [status] = 0 

this give results false status 7 days or older.

alternatively, where clause this:

where datediff(d, [date], getdate()) >= 7 , [status] = 0 

if absolutely must keep column nvarchar data type, date format provided, can convert datetime so:

convert(datetime, [date], 105) 

so where clause this:

where datediff(d, convert(datetime, [date], 105), getdate()) >= 7 , [status] = 0 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -