Free database script calculate date

Asked By 10 points N/A Posted on -
qa-featured

I have free database SQLite installed and don't know how to calculate the difference of two dates.

I have a table Person with two date fields: BirthDate and DeathDate.

I need to find the difference between the dates in years.

 

SHARE
Answered By 0 points N/A #132644

Free database script calculate date

qa-featured

Hello dear,

It's very simple question. You can this using PHP and MySQL.

Suppose  you have two values

Birthday = 1-1-2000 and Dead Day = 1-1-2012

Convert both values in to milli second using this function mktime(). Visit php.net for more about this function.

After converting both values you will see dead day value will be bigger than birthdays' value. Apply subtraction method on both values. You will get difference between them. You will get value in milli second. Convert your value into simple date using PHP function and store in database or simple show to the user

If any thing is unclear you can ask me. I am here for you.

Related Questions