You can download this code by clicking the button below.
This code is now available for download.
Calculates age based on the birthdate
Technology Stack : datetime, json
Code Type : Function
Code Difficulty : Intermediate
import datetime
import json
def calculate_age(birthdate):
today = datetime.date.today()
return today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))