Calculate the Date Age forumula

Kenny Gua 411 Reputation points

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

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

    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

    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?