Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python calculate age from date of birth

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

age calculator in python

import datetime 
Year_of_birth = int(input("In which year you took birth:- "))
current_year = datetime.datetime.now().year
Current_age = current_year - Year_of_birth
print("Your current age is ",Current_age)
Comment

how to find current age from date of birth in python

today_date = datetime.datetime.now()
dob = datetime.datetime(1982, 5, 20)
print(today_date - dob)
Comment

Calculate age python

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

python calculate age from date of birth

#Python Calculate Age from date of birth:

from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
Comment

age calculator in python


from datetime import date

def calculate_age(born):
    today = date.today()
    return today.year - born.year - ((today.month, today.day) < (born.month, born.day))

Comment

how to calculate the age from date of birth in python

SELECT DATEDIFF (
	year, DOB, getdate()) + CASE 
      WHEN (DATEADD(year,DATEDIFF(year, DOB, getdate()) , DOB) > getdate())
      THEN - 1 
      ELSE 0
END
)
Comment

how to calculate the age from date of birth in python

SELECT CASE WHEN dateadd(year, datediff (year, DOB, getdate()), DOB) > getdate()
            THEN datediff(year, DOB, getdate()) - 1
            ELSE datediff(year, DOB, getdate())
       END as Age
FROM <table>
Comment

age calculator python

import datetime
def Age_Calculator():
    '''create a python function that takes user birth year & month & day and prints
how old he is
args:name,birthday,birthmonth,birthyear
return : current age in years&monthand days
'''
    name = input("please enter your name :".title())
    today = datetime.date.today()
    birthday, birthmonth, birthyear = int(input("enter your bithday : ".title())), int(
        input("enter your bithmonth : ".title())), int(input("enter your bithyear : ".title()))
    # input birth year& month and day
    my_age_year, my_age_month, my_age_day = abs(
        today.year-birthyear), abs(today.month-birthmonth), abs(today.day-birthday)
    # get current age from today-my_birthdate
    nex_birthdate = datetime.date(today.year+1, birthmonth, birthday)
    #birth date in next year
    num_day = nex_birthdate-today
    print(
        f"congratulations {name} your age is {my_age_year} years & {my_age_month} month and {my_age_day} days".title())
    print(
        f"congratulations {name} your next birthdate after {num_day.days} days ".title())
Age_Calculator()
Comment

AGE CALCULATOION IN PYTHON

#AGE CALCULATOION IN PYTHON:

def calculator(age):
    age = (2022 - int(age))
    print("You are "+str(age)+" years Old")
calculator(input("Type your Birth Year: "))

#The easy way to calculate anyones age.Very simple trick.
# Just call a function
Comment

PREVIOUS NEXT
Code Example
Python :: how to get a hyperlink in django 
Python :: np vstack 
Python :: python datetime module 
Python :: django objects.create() 
Python :: hide code in jupyter notebook 
Python :: python log10 
Python :: try open file 
Python :: opencv erosion 
Python :: django static files / templates 
Python :: python replace char in string 
Python :: perimeter of circle 
Python :: how to delete a column from a dataframe in python 
Python :: sort dict by values 
Python :: python iterate through files in directory 
Python :: loop through python object 
Python :: remove a column from dataframe 
Python :: after groupby how to add values in two rows to a list 
Python :: how to append list to list in python 
Python :: python reserved keywords 
Python :: python check for duplicate 
Python :: get just filename without extension from the path python 
Python :: python raw string 
Python :: plot size 
Python :: python read entire file 
Python :: how to take input in python 
Python :: django migrate fake zero 
Python :: import excel python 
Python :: remove keys from dict python 
Python :: label point matplotlib 
Python :: joining pandas dataframes 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =