Show Expired data using DateAdd function in SQL Server -


i want show data expired or data going expire in 1 month. have 2 columns of dates use different reasons , want check both columns. example:

productname   date1          date2 xyz           5/8/2015       9/7/2015  mlk           8/2/2015       5/3/2016 gml           4/4/2017        7/8/2017 mmm           5/8/2016        7/30/2015 

desired results:

 productname   date1          date2     xyz           5/8/2015       9/7/2015      mlk           8/2/2015       5/3/2016     mmm           5/8/2016        7/30/2015 

i want show xyz because date1 has expired. want show mlk because date1 expire in 1 month. want show mmm because date2 expire in 1 month.
please help. thanks

so want know when date1 or date2 less 1 month today. using dateadd, can date 1 month on today, compare using <:

select * yourtable date1 < dateadd(mm, 1, getdate()) or date2 < dateadd(mm, 1, getdate()) 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -