Calculate the Date Age forumula

Kenny Gua 411 Reputation points
2022-10-24T13:51:30.89+00:00

Hi, I want to know if today date is '2023-01-01' then I want to deduct 64 year and 6 month to know what will the date (yyyy-mm-dd'). Please provide the query to calculate.

If today date is : 2023-01-01
Assuming less 64.5 year wil be :1958-06-30

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,459 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 106.4K Reputation points
    2022-10-24T14:16:13.507+00:00

    Check an example:

    declare @today datetime = '2023-01-01'  
      
    select dateadd(month, -6, dateadd(year, -64, @today))  
    
    1 person found this answer helpful.
    0 comments No comments

  2. Kenny Gua 411 Reputation points
    2022-10-24T17:50:48.937+00:00

    if we do calculation from 6 month then get 1958-07-01 result from as per your query and
    if we do calculation from 180 days then get 1958-06-30 result. Why one day difference from these two?