Page 1 of 1

Help in mysql?

Posted: Fri Feb 12, 2010 5:20 am
by adilmarwat2004
I have mysql database and contains table "act" which have 4 fields name

id, name, date_birth, date_of_retire
1 Jam 03-09-1987
2 Johnson 04-01-1992



I want to set a query for 'date_of_retire' as that it adds 60 years with 'date_birth' and display in
'date_of_retire' field.

please help.

Adil

Re: Help in mysql?

Posted: Fri Feb 12, 2010 5:34 am
by papa
An easy way would be to substr that baby.

Code: Select all

// fetch data 
$date_birth = '03-09-1987'
$year = substr($date_birth, -4);
 
$year += 60;
 
$date_birth = substr($date_birth, 6). $year;
 
// insert data

Re: Help in mysql?

Posted: Fri Feb 12, 2010 5:37 am
by adilmarwat2004
Dear!

I just want to set the query in mysql not in php.

Re: Help in mysql?

Posted: Fri Feb 12, 2010 5:47 am
by papa
Aha missed that.

Well MySQL have similar functions, check out the documentation.