• f9c882q 61644 (7/2/2013)


    How I create a function to get all policies that expire a 120 days from now.

    Eg If the policy effectivedate is November 1 2012 and expiration date is November 1 2013 then on july first when I run a query this policy should be selected.

    So you want to find all rows where the ExpirationDate is less than the current date + 120 days? Your question and your example are not quite the same. I will assume that my interpretation is correct. This is really not too difficult by using DATEADD.

    Where ExpirationDate < dateadd(day, 120, getdate())

    Now I am reading your post again and it is more confusing. If you add 120 days to July 1st you do NOT get November 1st, it is October 29th. Do you really mean 3 months instead of 120 days?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/