Re: [SQL] Datetime conversion in WHERE clause

2004-09-09 Thread Josh Berkus
Philippe, > Is there a way to force the date conversion to fail sliently, and simply > return a null in case the parameter is not a valid date? You'd need to write a custom function, using an external language that allows you to test for valid date values. I prefer using PL/perlU with Date::M

[SQL] Datetime conversion in WHERE clause

2004-09-09 Thread Philippe Lang
Hello, I'm converting a varchar to a date in a search routine which looks like: -- CREATE FUNCTION public.search_data(varchar) RETURNS SETOF foo1 AS ' SELECT DISTINCT foo1.* FROM foo1 LEFT JOIN foo2 ON foo2.fk = foo1.pk WHERE lower

Re: [SQL] Datetime

2004-08-03 Thread Michael Glaesemann
On Aug 4, 2004, at 7:55 AM, Tom Lane wrote: Sorry if I added to the confusion instead of dispelling it. Not at all. I had no idea how timestamps are stored internally, but I do now. I just knew it wasn't UNIX epoch or the same as the text representation displayed in results. Your explanation has

Re: [SQL] Datetime

2004-08-03 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > I don't quite understand how I am wrong in saying that PostgreSQL does > not use UNIX epoch timestamps internally, as you've clearly explained > it doesn't. We are talking at cross-purposes. I thought you were suggesting that PG doesn't use a sec

Re: [SQL] Datetime

2004-08-03 Thread Michael Glaesemann
On Aug 4, 2004, at 12:13 AM, Tom Lane wrote: Michael Glaesemann <[EMAIL PROTECTED]> writes: No. I'm just saying that PostgreSQL does not represent or store timestamps as epoch timestamps internally. You're wrong. It's not exactly Unix-like because we use a different epoch date (2000-1-1 not 1970-1-

Re: [SQL] Datetime

2004-08-03 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > No. I'm just saying that PostgreSQL does not represent or store > timestamps as epoch timestamps internally. You're wrong. It's not exactly Unix-like because we use a different epoch date (2000-1-1 not 1970-1-1) but the concept is just the same: w

Re: [SQL] Datetime

2004-08-03 Thread Michael Glaesemann
On Aug 3, 2004, at 8:50 PM, Achilleus Mantzios wrote: O kyrios Michael Glaesemann egrapse stis Aug 3, 2004 : I believe this is incorrect. I believe PostgreSQL uses its own Do you suggest postgresql has any other means of getting time except the time(2) syscall?? timestamp datatype internally (which

Re: [SQL] Datetime

2004-08-03 Thread Achilleus Mantzios
O kyrios Michael Glaesemann egrapse stis Aug 3, 2004 : > > On Aug 3, 2004, at 7:23 PM, Achilleus Mantzios wrote: > > > now() returns the current UNIX (your running UNIX right?) timestamp > > which > > in turn is > > measured in seconds,miliseconds since the epoch. > > i.e. 1970-01-01 00:00:00 >

Re: [SQL] Datetime

2004-08-03 Thread Michael Glaesemann
On Aug 3, 2004, at 7:23 PM, Achilleus Mantzios wrote: now() returns the current UNIX (your running UNIX right?) timestamp which in turn is measured in seconds,miliseconds since the epoch. i.e. 1970-01-01 00:00:00 I believe this is incorrect. I believe PostgreSQL uses its own timestamp datatype in

Re: [SQL] Datetime

2004-08-03 Thread Achilleus Mantzios
O kyrios Pedro B. egrapse stis Aug 3, 2004 : > Hello, > > I'm using a TIMESTAMP column with a now() default which (correctly i > assume) uses a '-mm-dd hh:mm:ss' format. Wrong!, timestamp does not use any human readable format to be stored. Its not like MS* tools where dates/times are actua

Re: [SQL] Datetime

2004-08-03 Thread Devrim GUNDUZ
Hi, On Tue, 3 Aug 2004, Pedro B. wrote: > I'm using a TIMESTAMP column with a now() default which (correctly i > assume) uses a '-mm-dd hh:mm:ss' format. > > Is it possible to make it something like '-mm-dd hh:mm:ss:cc' ? > (basically, a DATE and a TIME, but with 2 decimal cases on th

Re: [SQL] Datetime

2004-08-03 Thread Michael Glaesemann
On Aug 3, 2004, at 4:22 PM, Pedro B. wrote: Is it possible to make it something like '-mm-dd hh:mm:ss:cc' ? (basically, a DATE and a TIME, but with 2 decimal cases on the :cc and not .c as the TIME format. timestamp and timestamptz both take an optional precision parameter. What you want

[SQL] Datetime

2004-08-03 Thread Pedro B.
Hello, I'm using a TIMESTAMP column with a now() default which (correctly i assume) uses a '-mm-dd hh:mm:ss' format. Is it possible to make it something like '-mm-dd hh:mm:ss:cc' ? (basically, a DATE and a TIME, but with 2 decimal cases on the :cc and not .c as the TIME format. Tha

Re: RES: [SQL] Datetime problem

2004-06-14 Thread Tom Lane
"Alexander M. Pravking" <[EMAIL PROTECTED]> writes: > Hmm, 7.3 and 7.4 docs say that it returns timestamp (WITHOUT time zone > is default since 7.3 IIRC), but in fact it accepts and returns timestamp > WITH time zone. This is probably a documentation bug... Yeah, it is. Fixed in CVS tip --- thank

Re: RES: [SQL] Datetime problem

2004-06-14 Thread Tom Lane
"Eric Lemes" <[EMAIL PROTECTED]> writes: > - PostgreSQL 7.3.2 on i386-redhat-linux GCC 3.2.2 > - Timezone: Brazil (GMT-3, I think). Ah, and 2004-10-10 is a daylight savings transition day where you live, right? (Or at least the obsolete timezone file you have thinks so...) So local midnight on th

Re: RES: [SQL] Datetime problem

2004-06-14 Thread Alexander M. Pravking
On Mon, Jun 14, 2004 at 01:20:14PM -0300, Eric Lemes wrote: > Hello, > > - PostgreSQL 7.3.2 on i386-redhat-linux GCC 3.2.2 > - Timezone: Brazil (GMT-3, I think). What's about daylight saving time for you? I'm almost sure the DST boundary is near the date in your example. However, with 7.3.4 on F

RES: [SQL] Datetime problem

2004-06-14 Thread Eric Lemes
date is in GMT? Thanks for all your help. []'s Eric Lemes > -Mensagem original- > De: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] nome de Tom Lane > Enviada em: segunda-feira, 14 de junho de 2004 11:56 > Para: Eric Lemes > Cc: [EMAIL PROTECTED] > Assu

Re: [SQL] Datetime problem

2004-06-14 Thread Tom Lane
"Eric Lemes" <[EMAIL PROTECTED]> writes: > - select to_timestamp('2004 10 10 00 00 00', ' MM DD HH MI SS') > the output is: > - 2004-10-09 23:00:00-03 What PG version is this, on what platform, and what's your current timezone setting? regards, tom lane --

Re: [SQL] Datetime problem

2004-06-14 Thread Achilleus Mantzios
O kyrios Eric Lemes egrapse stis Jun 14, 2004 : > Hello there, > > I'm with a little trouble with postgresql and date/time conversions: > > - select to_timestamp('2004 10 10 00 00 00', ' MM DD HH MI SS') > > the output is: > > - 2004-10-09 23:00:00-03 Just do select to_timestamp('2004 10

Re: [SQL] Datetime problem

2004-06-14 Thread Stef
Hello Eric, Are you looking for something like : select to_char(timestamp 'now',' MM DD HH MI SS'); or the values in your example below : select to_char(timestamp '20041010 00:00:00',' MM DD HH MI SS'); Eric Lemes mentioned : => Hello there, => => I'm with a little trouble with postgresq

[SQL] Datetime problem

2004-06-14 Thread Eric Lemes
Hello there,   I'm with a little trouble with postgresql and date/time conversions:   - select to_timestamp('2004 10 10 00 00 00', ' MM DD HH MI SS')   the output is:   - 2004-10-09 23:00:00-03   Anybody can help me?     []'s   Eric Lemes de Godoy Cintra Analista de Sistemas Líder

Re: [SQL] Datetime Query

2001-02-16 Thread Jie Liang
Try: SELECT request_no FROM request where status_code ='C' and (completed_date::date between '01/01/2000'::date and '01/01/2001'::date) actually date('01/01/2000') does same thing as '01/01/2000'::date Jie LIANG St. Bernard Software Internet Products Inc. 10350 Science Center Drive Suite 10

[SQL] Datetime Query

2001-02-16 Thread Mark Byerley
I need to create a query which will select a request_no between Data1 and Date2 so... SELECT request_no FROM request where status_code ='C' and (completed_date between 01/01/2000 and 01/01/2001); The problem I have run into is that the completed_date field is a datetime format (not by my own