Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:54:32+00:00 2026-06-11T10:54:32+00:00

Input : Month, Year, GraceMonth. All are in Integer. What we need to do

  • 0

Input :

Month, Year, GraceMonth. All are in Integer.

What we need to do ?

First need to construct the date from Month, Year and Day(need to get from the current date)
and then add GraceMonth to it.We will get the new Date obviously after adding the GraceMonth.
Next, from the date constructed, we need to compare that with the current date.

What have you tried?

e.g. ( I am showing in Parts)

DECLARE @Month INT = 11
DECLARE @YEAR INT = 2012
DECLARE @Graceperiod INT = 2 

SELECT 
    [Construct Initial Date] = DATEADD(mm, (@YEAR - 1900) * 12 + @Month - 1 , DAY(GETDATE()) - 1) --construct initial date  
    ,[Add Grace period] =DATEADD(mm,@Graceperiod,DATEADD(mm, (@YEAR - 1900) * 12 + @Month - 1 , DAY(GETDATE()) - 1)) --add grace month
    ,[DateDiff] = DATEDIFF
            (
                DAY,
                DATEADD(mm, (@YEAR - 1900) * 12 + (@Month + @Graceperiod) - 1 , DAY(GETDATE()) - 1),
                GETDATE()
             ) -- datediff

Result

Construct Initial Date        Add Grace period              DateDiff
2012-11-14 00:00:00.000       2013-01-14 00:00:00.000      -122

If your answer is correct, then what are you looking for?

Is there any other good approach apart from this? The more concise without Casting, the better. And please provide explanation if it involves some tricky part (e.g. some tricky mathematical calculation).

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:54:33+00:00Added an answer on June 11, 2026 at 10:54 am
    DECLARE @Month INT = 11
    DECLARE @YEAR INT = 2012
    DECLARE @Graceperiod INT = 2 
    
    SELECT 
          [Construct Date] = DATEADD(mm, (@YEAR - 1900) * 12 + @Month - 1 , DAY(GETDATE()) - 1) --construct date
          ,[Add Grace period] =DATEADD(mm,@Graceperiod,DATEADD(mm, (@YEAR - 1900) * 12 + @Month - 1 , DAY(GETDATE()) - 1)) --add grace month
          ,[DateDiff] = DATEDIFF(
                            DAY,
                            DATEADD(mm,@Graceperiod,DATEADD(mm, (@YEAR - 1900) * 12 + @Month - 1 , DAY(GETDATE()) - 1)),
                            GETDATE()
                      ) -- datediff
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have input xml as <content> <date> <day>14</day> <month>06</month> <year>2012</year> </date> </content> want it
i get a date input from the user..in this case i need to determine
I need to be able to store a date (year/month/day) with no time component.
I need formtastic to display only month and year fields, WITHOUT the day fields.
Hey guys i have two date inputs containing three dropboxes for day,month and year
I have a dataset with a column containing date in DAY-MONTH-YEAR TIME format. That
My input is month and year in integer. month year 8 2011 9 2012
The input string is '20100908041312' the format is year,month,day,Hours,minutes,seconds,time zone and I have ben
I have params[:month,:day,:year] and I need to convert them into a DateTime that I
I have a form with 3 dropdown boxes to select Month/Day/Year. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.