hello friends i want to make employee registration form by using HTML & CSS as User Interface, Python as Script and PostgreSQL as database,here i want to know, how to calculate age from Date Field in HTML User interface,herewith my Python Program,
#!C:\Python27\python.exe
# Import modules for CGI handling
import cgi, cgitb
from datetime import datetime
import datetime
import psycopg2
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
empname = form.getvalue('empname') //getting employee name from html text field
if form.getvalue('gender'):
gender=form.getvalue('gender') //getting gender from html radio button
else:
gender="Not set"
dob = form.getvalue('dob') //getting date of birth from html date field
//here i want to calculate and store age into database here
address = form.getvalue('address')
pincode = form.getvalue('pincode')
mobile = form.getvalue('mobile')
doj = form.getvalue('doj') // dote of joining
db = psycopg2.connect(database="employee", user="postgres", password="jeba", host="localhost", port="5432")
cursor = db.cursor()
cursor.execute("INSERT INTO emp_details(empname, gender, dob, age, address, pincode, mobile, doj) \
VALUES('"+empname+"', '"+gender+"', '"+dob+"', "+age+", '"+address+"', "+pincode+", "+mobile+", '"+doj+"')");
db.commit()
db.close()
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Employee Details</title>"
print "</head>"
print "<body>"
print "<h1>Success</h1>"
print "<h1>age is "+age+"</h1>"
print "</body>"
print "</html>"