sacredeagle@gmail.com (Helgi Örn) writes:
> Hi! I am moving a database project from MySQL to PostgreSQL I was a
> newbie there and now I am a newbie here :)
>
> I have this form mysql:
> SELECT tid_in, TIME_FORMAT(tid_in, '%H.%i')AS format FROM timmar;
>
> Which I have gotten postgre to accept thus far:
> SELECT pack_tidin TIME_FORMAT, pack_tidin '%H.%i', AS format FROM timmar;
>
> it stops at AS which doesn't seem to exist is postgre, what is
> postgres alternative to AS?
I see two problems here...
1. You need to use Postgres idioms for the reformatting of the date.
<http://www.postgresql.org/docs/9.0/static/functions-formatting.html>
2. You put in a syntax error when you put in an extra comma.
Instead of:
> SELECT pack_tidin TIME_FORMAT, pack_tidin '%H.%i', AS format FROM timmar;
^
Take out the comma to get:
SELECT pack_tidin TIME_FORMAT, pack_tidin '%H.%i' AS format FROM timmar;
Possibly a more suitable query would be:
select pack_tidin, to_char (pack_tidin, 'HH.MI') as format from timmar;
I'm assuming that '%H.%i' is intended to return hours and minutes,
separated by a ".". You can probably get more useful guidance from the
URL listed above.
--
(format nil "~S@~S" "cbbrowne" "acm.org")
http://linuxfinances.info/info/postgresql.html
We're Thinking Machines, so we don't have to.