I am trying to write a python statement to calculate a user's dob in a mysql db. The dob is a auto-populated field (based off his profile) in a form that a user fills out.
We write python code directly into the fields in our mysql db that perform calculations on runtime. An example:
date.today().strftime("%m-%d-%Y")
for today's date.
But I have never used it in reference to another field on the same form, so I am unsure how to do this. I have tried:
(date.today() - dob) / timedelta(days=365.2425).strftime("%m-%d-%Y")
where dob is the field on the form where the user's date of birth is auto-populated.
What am I missing? I receive a 'syntax error', probably because it doesn't know what the dob variable is, but I don't know how to point to that field's value to make it perform the calc. Any help would be appreciated!