This topic is locked

Display Date

10/4/2006 5:47:56 PM
PHPRunner General questions
P
pauloc author

In the edit page I can choose to edit a date as a dropdown box in DD MM YYYY format but when I retun to the list page it is always displayed as YYYY-M-D.

Living in Australia I really want it diplayed as DD-MM-YYYY
From this I then want to calculate the users age, but one thing at a time.
Thanks

Paul

Alexey admin 10/5/2006

Paul,
open List page in Visual Editor, double click on your date field and set its View type to Short Date.

P
pauloc author 10/5/2006

Paul,

open List page in Visual Editor, double click on your date field and set its View type to Short Date.


Thanks, such a simple solution. What a great product.
Now part 2.

How do I calcumate age?

Alexey admin 10/5/2006

Paul,
please tell me where and when you want to calculate age.

P
pauloc author 10/5/2006

Paul,

please tell me where and when you want to calculate age.


I have a page and table for personal details.

One field is date of birth.

After the user has edited the page and entered their details I would like to list page to show both date of birth and current age in years.

Alexey admin 10/6/2006

Paul,
you can do this adding calculated field to your SQL query on Edit SQL query tab in PHPRunner.

Here is the sample code:

select

...

BirthDate,

Year(Now())-Year(Birthdate) as Age

from ...


where BirthDate is your actual field name.
Here is more precise version of the code however it will work with MySQL 5 only.

select

...

BirthDate,

TIMESTAMPDIFF(YEAR,Birthdate, NOW()) as Age

from ...