Re: Converting a date to a string
Posted in 1998
Avi Abrami <avia@telegate.co.il> writes: > Bob Neidecker wrote: > > > How do I convert a date to a string so that I can have the following where > > clause > > > > WHERE date_column LIKE '12/%1/98' > > > > I want users to be able to use wildcards in strings. I know there is a > > performance hit. Since you cannot do a like on a date column you must > > first convert it to a string using some sort of string conversion operator. > > I am new to Informix but in Oracle the where clause would look like > > > > WHERE TO_CHAR(date_column ,'MM/DD/YYYY') LIKE '12/%1/1998'. > > > > In sybase it would look like > > > > WHERE convert(char(10), date_column, 101) LIKE '12/%2/1998' > > > > Bob Neidecker > > bob_neidecker@mail.amsinc.com > > > > > > Try this ... > > WHERE date_column::CHAR(10) LIKE '12/%2/98' This requires casting, which is only avaliable in 9.X (Universal Data Option). In 7.30 you can use to_char(): ... WHERE to_char(date_column,'%m/%d/%Y') like "12/%1/1998" You may also omit the formatting string, and it will use your GL_DATE or your DBDATE environment variables. -- 'yvind Gjerstad Systems dept Tollpost-Globe AS N-6301 'ndalsnes/Norway E-mail: ogj@it.tollpost.no Phone: +47 7122 6663 Fax: +47 7122 6694