I need to write a function or SP that will return the first occurance of the 15th. For example, if I pass the date as May 8th, then it should return May 15th. If I pass May 30th, then it should return June 15th.
One way
   DECLARE @d DATETIME
    SELECT @d = '20110508'
    --SELECT @d = '20110530'
    SELECT  CASE WHEN DAY(@d)  > 15 
    THEN  dateadd(mm, datediff(mm, 0, @d)+1, 0) + 14
    ELSE dateadd(mm, datediff(mm, 0, @d)+0, 0)+ 14 end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With