Re: formating a DATETIME into a string
Posted in 1997
On 13 Nov 1997, Steen N. Hansen wrote: > how do i make a format on a datetime, in a way like formating a date > type: > > x char (30) > let x = today using "dd.mm.yyyy" > > is there some special function? Not in I4GL, as such. Which is not to say that you couldn't write your own. > or do i have to build one my self: > > x charr (30), ^ syntax error: the construct is not recognizable in this context :-) > xdate datetime year to fraction > > let xdate = current > let x = xdate using "dd.mm.yyyy HH:MM:SS" ??????? In some respects, it would not be too hard; there are various datetime formatting routines available in ESQL/C (dttofmtasc(), etc), or you could fall back on strftime() in ANSI C. However, these routines are all loosely in the printf-family and use '%X' style notations to indicate which elements of the date/time value are to be printed. You would have to write a parser to convert strings such as "dd.mm.yyyy HH:MM:SS" into the equivalent "%d.%m.%Y %H:%M:%S". You also wouldn't be able to use the USING clause; you'd have to write: LET x = format_datetime(xdate, "dd.mm.yyyy HH:MM:SS") Yours, Jonathan Leffler (johnl@informix.com) #include <witticism.h>