Share via

Date Calculation with specific date

Kenny Gua 431 Reputation points
Mar 28, 2023, 12:43 PM

Heloo, I want to subtract 64.5 years in Eff_Date-2022-12-05 and want to get the result after subtracting 64.5 years (2022-12-05 minus 64.5 yrs).

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Naomi Nosonovsky 8,331 Reputation points
    Mar 28, 2023, 1:01 PM

    Try

    DECLARE @date DATE = '2022-12-05'
    
    SELECT @date, DATEADD(MONTH, -1*64.5*12, @date) AS newDate
    
    
    1 person found this answer helpful.

  2. Naomi Nosonovsky 8,331 Reputation points
    Mar 28, 2023, 12:58 PM

    Try:

    DECLARE @date DATE = '2022-12-05'
    SELECT @date, DATEADD(MONTH, -1*64.5*12, @date) AS newDate
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.