Hang on! What is the number in the Birthday column? Can we format it with something like ${rec:Birthday|strftime:%d/%m/%Y}? Yes, you can do that. There is also an alternative way:
var phbook%decode:Birthday = "strftime:%d/%m/%Y";
And this needs to be done before the retrieval loop starts. In fact, you can change it on the fly and all subsequent record retrieval will use the new Conversion specification in the new "decode" variable. Now we have:
ID Name Tel Height Birthday
16 Joe Chan 98765432 178 22/03/2001
17 Dick Smith 87654321 147
Decoding automatically upon retrieval (the phbook%decode way) is implemented in the lower level BEE database engine and therefore is more general and powerful. Together with the "encode" variable, you can conceal the true value of the field entirely.
For example, if you allow update of the Birthday field in the above example, instead of updating with the value in timestamp format, you can update it directly with the date string. All you need to do is to define this:
var phbook%encode:Birthday = "strtotime";
When the Birthday field is inserted or updated, the date string (e.g. 26/12/1981) will be automatically converted to the timestamp format, as specified in the "encode" variable, before saving into the database. When the Birthday field is retrieved, it will be automatically converted to the date string format, as specified in the "decode" variable, before being made available to the script context. How the date is being implemented at the database level is transparent, once the "decode" and "encode" variable is defined for the field.
|