You must Sign In to post a response.
  • Category: SQL Server

    SQL Query to get Specific day on every month


    How can I find specific day on each month?

    If customer make registration on 1st January then I have to set reminder before two days of each month.

    Means if Customer's Registration date is 15th January then I want a data on 13th February,13th March onwards.

    if Customer's Registration date is 1st January then I want a data on 27th February,30th March,29th April onwards.

    Is there any solutions where I can find dates in this manner?
  • #768940
    Hai HArdik,
    You can calculate the day based on the current registration date. You application should check the registration date and ping to the system every-time at-least once so that when you say the Registration date is 1st Jan, it should get the next date by adding a month -2 days.
    For this, you can have an additional column for the table for next date which will have the specific day for the month.. Now lets say first time, it should check with the specific day and if it is null, then get the registration date and add a month -2 to get the next date and save it to the specific day column. Now next time again it should for the specific day value and it will not be null so get its value and add a month -2 value to it and update.
    So each time for every month it should do the same and update the specific day value. By this way, you can get the next date for every month.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #768962
    I guess this is solved by very simple sql query . Just DateAdd function will make this work like a charm.

    Select DATEADD(DAY, -3, GETDATE()) // GetDate() or your date which the registration made.

    So In place of GetDate() keep your registration date and the output you will get the before 3 days for the current registration date. It will work for the February month also without any further hiccups.


  • Sign In to post your comments