Re: [SQL] How to quote date value?

2003-11-28 Thread nobody
Thanks, I learnt to use:

SELECT CAST('1/11/2003' AS DATE) AS invoice_number;

and it does what I would expect ;-).

"Stephan Szabo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> On Fri, 21 Nov 2003, Gaetano Mendola wrote:
>
> > nobody wrote:
> > > I have found it in documentation, it is single quote. But it does not
> > > explain why
> > >
> > > SELECT '1/11/2003' AS "InvoiceDate";
> > >
> > > returns "unknown" data type instead of "date".
>
> (I haven't seen the original message yet, so I'm replying to a reply)
> Date literals are generally written as:
> DATE '1/11/2003'
>
> PostgreSQL will try to guess what type you meant with quoted strings in
> expressions, but in the above there isn't enough context to do guess that
> you meant a date really (it should probably actually be thought of as a
> string in such cases).
>
>
> ---(end of broadcast)---
> TIP 7: don't forget to increase your free space map settings
>



---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[SQL] How to quote date value?

2003-11-28 Thread nobody
What is correct character to quote date values in SELECT. Is is single
quote?

When I do:

SELECT '1/11/2003' AS "InvoiceDate";

the returned value is of unknown type (not a date).

Then I tried:

SELECT 1/11/2003 AS "InvoiceDate";

and the InvoiceDate was set to zero (I guess the engine divided the numbers
in date).

Then I tried:

SELECT 1-11-2003 AS "InvoiceDate";

and the numbers in date value got substracted.

Using PostgreSQL 7.4 and PgAdmin 3.

Any insight is welcome.



---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] How to quote date value?

2003-11-28 Thread nobody
I have found it in documentation, it is single quote. But it does not
explain why

SELECT '1/11/2003' AS "InvoiceDate";

returns "unknown" data type instead of "date".

"nobody" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> What is correct character to quote date values in SELECT. Is is single
> quote?
>
> When I do:
>
> SELECT '1/11/2003' AS "InvoiceDate";
>
> the returned value is of unknown type (not a date).
>
> Then I tried:
>
> SELECT 1/11/2003 AS "InvoiceDate";
>
> and the InvoiceDate was set to zero (I guess the engine divided the
numbers
> in date).
>
> Then I tried:
>
> SELECT 1-11-2003 AS "InvoiceDate";
>
> and the numbers in date value got substracted.
>
> Using PostgreSQL 7.4 and PgAdmin 3.
>
> Any insight is welcome.
>
>



---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] append columns that are null

2004-07-09 Thread nobody
You are welcome. Only if all problems were that simple ;-)...
"Gerwin Philippo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> THX! didn't know that one yet :)
>
> nobody wrote:
> > "Gerwin Philippo" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >
> >>I have function that appends 2 columns, like
> >>"new.field1 = new.field2||new.field3",
> >>but when field 3 is null, then the entire outcome is null, while I
> >>expected just field2, since when I append nothing to field2, I get
> >>field2, right?
> >>Is this standard behaviour, and if so, is there another append function
> >>that I can use that doesn't behave like this?
> >
> >
> > COALESCE is your friend...
> >
> >



---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] append columns that are null

2004-07-09 Thread nobody

"Gerwin Philippo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have function that appends 2 columns, like
> "new.field1 = new.field2||new.field3",
> but when field 3 is null, then the entire outcome is null, while I
> expected just field2, since when I append nothing to field2, I get
> field2, right?
> Is this standard behaviour, and if so, is there another append function
> that I can use that doesn't behave like this?

COALESCE is your friend...



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster