Get the month and year now then count the number of rows that are older then 12 months in SQL/Classic ASP -
i know 1 pretty easy i've had nightmare when comes comparing dates in sql please can me out this, thanks.
i need month , year of compare date stored in db.
time format in db:
2015-08-17 11:10:14.000
i need compare month , year , if > 12 months old increment count. need number of rows argument true.
i assume have datetime field.
you can use datediff function, takes kind of "crossed boundaries", start date , end date.
boundary month because interested in year , month, not days, can use month
macro.
start time value stored in table's row.
end time now. can system time selecting sysdatetime function.
so, assuming table called mtable
, datetime object stored in date
field, have query:
select count(*) mtable datediff(month, mtable.date, (select sysdatetime())) > 12
Comments
Post a Comment