Thread: problem with casting
I have a table that has a 'date' column. In psql I tried to do a select proofdate::text from openjobs where jobno = '10625'; responce: can not cast type 'date' to 'text' Did i miss-read this section. I thought I could cast the date to text. has anyone seen this or am I missreading the docs? thanks Ted
Ted, > responce: can not cast type 'date' to 'text' > > Did i miss-read this section. I thought I could cast the date to text. has anyone seen > this or am I missreading the docs? 'fraid so. You cannot cast Date as Text, because (presumably) the DB engine doesn't know how you want to format the date. Instead, use the to_char builtin function, as defined in the docs: http://www.postgresql.org/users-lounge/docs/7.0/postgres/functions2976.htm Share & Enjoy! -Josh Berkus -- ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete informationtechnology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco
In data Wed, 14 Feb 2001 21:10:30 +0000 (UTC), postgresql scrive: >I have a table that has a 'date' column. In psql I tried to do a > >select proofdate::text from openjobs where jobno = '10625'; > >responce: can not cast type 'date' to 'text' > >Did i miss-read this section. I thought I could cast the date to text. has anyone seen >this or am I missreading the docs? > select to_char(proofdate, 'dd/mm/yyyy') from openjobs where jobno = '10625';