Re: format date
Posted in 2006
I'm not sure when it was added (searching the net shows 7.31.UD1 may have it) but TO_CHAR is available in at least Informix 9.4x.xx (confirmed) and up. From the 9.4xx manual; TO_CHAR Function The TO_CHAR function converts a DATE or DATETIME value to a character string. The character string contains the date that was specified in the source_date parameter and represents this date in the format that was specified in the format_string parameter. You can use this function only with built-in data types. If the value of the source_date parameter is NULL, the function returns a NULL value. If you omit the format_string parameter, the TO_CHAR function uses the default date format to format the character string. The default date format is specified by environment variables such as GL_DATETIME and GL_DATE. The format_string parameter does not have to imply the same qualifiers as the source_date parameter. When the implied formatting mask qualifier in format_ string is different from the qualifier in source_date, the TO_CHAR function extends the DATETIME value as if it had called the EXTEND function. In the following example, the user wants to convert the begin_date column of the tab1 table to a character string. The begin_date column is defined as a DATETIME YEAR TO SECOND data type. The user uses a SELECT statement with the TO_CHAR function to perform this conversion. SELECT TO_CHAR(begin_date, '%A %B %d, %Y %R') FROM tab1 The symbols in the format_string parameter in this example have the following meanings. For a complete list of format symbols and their meanings, see the GL_DATE and GL_DATETIME environment variables in the IBM Informix GLS User's Guide. The result of applying the specified format_string to the begin_date column is as follows: Wednesday July 23, 1997 18:45 On 9/19/06, Fotopoulos Lefteris <lfot@obi.gr> wrote: > > > > Hello all, > > What is the Informix equivalent to oracle's function "TO_CHAR", for date > formatting? > > I want to format a date to string YYYYMMDD. > > Thanks > > > > > > Eleftherios Fotopoulos > > OBI-IT Information Services > > (: 210-6183614 > > +: lfot@obi.gr > > > > ********************************************************************** > > This email and any files transmitted with it are confidential and > > intended solely for the use of the individual or entity to whom they > > are addressed. If you have received this email in error please notify > > the system manager. > > ********************************************************************** > > > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list > > >