15,999,481 members
See more:
Need to calculate DOB month and age from given date of birth.

DOB:
`1988-10-20`
(YYYY-MM-DD)

I need output as

`10 and age of(1988-10-20) `

I have tried using it, but i coudn't get proper output.

```SELECT (DATEDIFF(MONTH,'1988-10-20',getdate()))-(DATEDIFF(YEAR,'1988-10-20',GETDATE())*12)  AS Smonth
```

But iam getting output as -1,

I need to get output as 10.

What I have tried:

`SELECT (DATEDIFF(MONTH,'1988-10-20',getdate()))-(DATEDIFF(YEAR,'1988-10-20',GETDATE())*12)  AS Smonth`
Posted
Updated 26-Sep-18 6:53am
v3

## Solution 3

See Solution 2 to this post How to calculate age from date of birth in sql[^]

## Solution 6

SQL
```DECLARE @DOB Date='07/03/1993';

SELECT CAST(ROUND((DATEDIFF(DAY,@DOB,GETDATE())/365.0),0) AS INT) AS AGE

OUTPUT:-
----
AGE
----
25```

v2

## Solution 7

`select convert(nvarchar(max),Month('1988-10-20'))+' and ' + convert(nvarchar(max), DATEDIFF(year, '1988-10-20',getdate()))+' age of '+'1988-10-20' as Age `

Output
----------------
10 and 30 age of 1988-10-20

v2

## Solution 4

To calculate month from given date

```Declare @DOB datetime='1988-10-20'
select Month(@DOB) [Month]```