Help in mysql?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adilmarwat2004
Forum Commoner
Posts: 44
Joined: Fri Sep 04, 2009 11:28 pm

Help in mysql?

Post 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
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help in mysql?

Post 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
adilmarwat2004
Forum Commoner
Posts: 44
Joined: Fri Sep 04, 2009 11:28 pm

Re: Help in mysql?

Post by adilmarwat2004 »

Dear!

I just want to set the query in mysql not in php.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Help in mysql?

Post by papa »

Aha missed that.

Well MySQL have similar functions, check out the documentation.
Post Reply