On Dec 19, 2006, at 5:13 AM, Sivakatirswami wrote:

Hypenated: YYYY-MM-DD,  zero padded comes standard with SQL
but in Rev we have to do little dances like:

FUNCTION internationalDate tDate
    convert tDate to dateitems
    IF len(item 2 of tDate<2) THEN put "0" before item 2 of tDate
    IF len(item 3 of tDate<2) THEN put "0" before item 2 of tDate
    return   (item 1 of  tDate &"-" & item 2 of tDate &"-" & item 3 of
tDate)
END internationalDate

?? am I missing  something?

For the padding problem, look up the format function, especially this bit :

Note: If a zero is included immediately before the charLength parameter in any formatting incantation that allows padding, the resulting value is padded (if necessary) with zeroes instead of spaces. For example, the incantation %03s transforms "H" to "00H".


Worthy of a feature request?

It would be fun to have something like:

   set the dateFormat to "YYYY-MM-DD"
   put the formattedDate

and

   set the timeFormat to "HH:MM"
   put the formattedTime

where I could even specify:

   set the timeFormat to "H hours and M minutes"

and have the formattedTime return "03 hours and 55 minutes"

or something similar.

Though with format() and merge() you can pretty much get the same thing :

FUNCTION internationalDate tDate
     constant k4pad="%04d", k2pad="%02d"
constant kDateStr="[[ format(k4pad,item 1 of tDate) ]]-[[format (k2pad, item 2 of tDate) ]]-[[format(k2pad, item 3 of tDate) ]]"
     convert tDate to dateitems
     return merge(kDateStr)
end internationalDate

Which you can customize for different formats.


t


(Alfredo Dawes)



--
Tereza Snyder

   Califex Software, Inc.
   www.califexsoftware.com

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to