---
title: "How do I calculate someone's age in C#?"  
description: "How do I calculate someone's age in C#?"  
author: "Anonymous User"  
published: 2013-12-27  
updated: 2013-12-27  
canonical: https://www.mindstick.com/forum/1842/how-do-i-calculate-someone-s-age-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How do I calculate someone's age in C#?

Given a [DateTime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) representing a person's birthday, how do I calculate their [age](https://www.mindstick.com/articles/23262/the-modern-age-these-technology-trends-can-make-your-life-easier)?

## Replies

### Reply by Anonymous User

Hi Chintoo,You can calculate the age like this:\

```
DateTime today = DateTime.Today;int age = today.Year - bday.Year;if (bday > today.AddYears(-age)) age--;
```


---

Original Source: https://www.mindstick.com/forum/1842/how-do-i-calculate-someone-s-age-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
