Re: [SQL] Date Index

2012-11-05 Thread Tom Lane
Adam Tauno Williams writes: > OGo=> create index job_date_only on job(extract(date from start_date at > time zone 'utc')); > ERROR: timestamp units "date" not recognized There's no field called "date" in a timestamp. I think what you're trying to achieve is "date_trunc('day', start_date at tim

Re: [SQL] Date Index

2012-11-05 Thread Adam Tauno Williams
On Fri, 2008-10-31 at 08:48 +0100, A. Kretschmer wrote: > am Thu, dem 30.10.2008, um 14:49:16 -0600 mailte Ryan Hansen folgendes: > > Hey all, > > I?m apparently too lazy to figure this out on my own so maybe one of you can > > just make it easy on me. J > > I want to index a timestamp field but

Re: [SQL] date arithmetic with columns

2012-03-06 Thread Peter Faulks
Good question. I'm porting a (never actually finished) app from Firebird to Postgres. Now that I've re-read how the timestamptz (which Firebird doesn't have) actually works, I think I'll change the tables and get rid of the timezone lookup. Thanks On 4/03/2012 8:45 PM, hari.fu...@gmail.com

Re: [SQL] date arithmetic with columns

2012-03-04 Thread hari . fuchs
Peter Faulks writes: > I have two columns in two distinct tables, one is the starting time of > an event, timestamp without time zone. Data is the utc datetime (for > sorting across time zones), the other is the number of minutes to add. Maybe I'm missing something, but why don't you just use ti

Re: [SQL] date arithmetic with columns

2012-03-03 Thread Pavel Stehule
Hello 2012/3/1 Peter Faulks : > Bit more googling and I came up with: > > r.utc + CAST( tz.diffmins || ' ' || 'minutes' AS interval) > > It works, but is it the best way? > r.utc + tz.diffmins * interval '1 minute' regards Pavel Stehule > > On 1/03/2012 6:50 AM, Peter Faulks wrote: >> >> I ha

Re: [SQL] date arithmetic with columns

2012-03-03 Thread Peter Faulks
Bit more googling and I came up with: r.utc + CAST( tz.diffmins || ' ' || 'minutes' AS interval) It works, but is it the best way? On 1/03/2012 6:50 AM, Peter Faulks wrote: I have two columns in two distinct tables, one is the starting time of an event, timestamp without time zone. Data is the

Re: [SQL] date range to set of dates expansion

2012-01-20 Thread Gary Stainburn
On Thursday 19 January 2012 16:50:53 Steve Crawford wrote: > I'm sure most here would recommend moving to 9.1 rather than 8.4. Better > performance, cooler replication functionality, more advanced in-place > upgrade capabilities for future upgrades, a couple years longer before > end-of-life, advan

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Adrian Klaver
On 01/19/2012 09:17 AM, Samuel Gendler wrote: On Thu, Jan 19, 2012 at 8:20 AM, Adrian Klaver mailto:adrian.kla...@gmail.com>> wrote: On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > The following code works in 8.4 but not 8.3. > Anyone know why, or what I need to

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Samuel Gendler
On Thu, Jan 19, 2012 at 8:20 AM, Adrian Klaver wrote: > On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > > The following code works in 8.4 but not 8.3. > > Anyone know why, or what I need to do to change it? > > > > SELECT aid, asid, > >date_range (asdate, afdate)::date AS

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Steve Crawford
On 01/19/2012 07:16 AM, Gary Stainburn wrote: On Thursday 19 January 2012 15:11:46 Gary Stainburn wrote: I'll be upgrading my live server as soon as possible, but in the meantime can anyone suggest a way I can do the same thing using Postgresql 8.1 until I can evaluate 8.4 on my live systems? I

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Adrian Klaver
On Thursday, January 19, 2012 7:59:27 am Gary Stainburn wrote: > The following code works in 8.4 but not 8.3. > Anyone know why, or what I need to do to change it? > > SELECT aid, asid, >date_range (asdate, afdate)::date AS asdate, >acomments > FROM availability > > In 8.4 it retu

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
The following code works in 8.4 but not 8.3. Anyone know why, or what I need to do to change it? SELECT aid, asid, date_range (asdate, afdate)::date AS asdate, acomments FROM availability In 8.4 it returns the expanded dataset as required. In 8.3 I get: ERROR: set-valued function

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
On Thursday 19 January 2012 15:11:46 Gary Stainburn wrote: > I'll be upgrading my live server as soon as possible, but in the meantime > can anyone suggest a way I can do the same thing using Postgresql 8.1 > until I can evaluate 8.4 on my live systems? Sorry, I meant 8.3 as my current version

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread Gary Stainburn
On Thursday 19 January 2012 08:32:27 hari.fu...@gmail.com wrote: > > Why don't you just use the built-in PostgreSQL function for that? > > SELECT aid, asid, >generate_series (asdate, afdate, INTERVAL '1 day')::date AS asdate, >acomments > FROM tbl 1) because I didn't know about it

Re: [SQL] date range to set of dates expansion

2012-01-19 Thread hari . fuchs
Gary Stainburn writes: > Hi, > > How can I expand a date range in a table to a set of date records? > > I have a table of availabilities thus: > > Column |Type | Modifiers > ---+-+-

Re: [SQL] Date comparison, user defined operators and magic

2010-02-26 Thread Tom Lane
Petru Ghita writes: > Hello everybody, I was missing a comparison operator for DATE so I > wrote one after a really fast look into the documentation. Huh? regression=# \do < List of operators Schema | Name |Left arg type|

Re: [SQL] date + interval year - why is the return type convered to a timestamp?

2009-10-22 Thread Tom Lane
the6campbells writes: > Why is Postgres returning a timestamp instead of the expected date data type > for the first expression (the second returns a date)? > select date '2001-03-30' - interval '1' year, date '2001-03-30' - integer > '365' from tversion Would you expect a date for date

Re: [SQL] Date Index

2008-11-03 Thread Tom Lane
"Ryan Hansen" <[EMAIL PROTECTED]> writes: > Incidentally, extract(date from ts) doesn't work on my install of 8.3 The field names recognized by extract() are quite well documented http://www.postgresql.org/docs/8.3/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT and "date" isn't one of

Re: [SQL] Date Index

2008-11-03 Thread Ryan Hansen
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A. Kretschmer Sent: Friday, October 31, 2008 1:49 AM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Date Index am Thu, dem 30.10.2008, um 14:49:16 -0600 mailte Ryan Hansen folgendes: > Hey all, > > >

Re: [SQL] Date Index

2008-10-31 Thread A. Kretschmer
am Thu, dem 30.10.2008, um 14:49:16 -0600 mailte Ryan Hansen folgendes: > Hey all, > > > > I?m apparently too lazy to figure this out on my own so maybe one of you can > just make it easy on me. J > > > > I want to index a timestamp field but I only want the index to include the > -mm

Re: [SQL] Date Index

2008-10-30 Thread Scott Marlowe
On Thu, Oct 30, 2008 at 2:49 PM, Ryan Hansen <[EMAIL PROTECTED]> wrote: > Hey all, > > > > I'm apparently too lazy to figure this out on my own so maybe one of you can > just make it easy on me. J > > > > I want to index a timestamp field but I only want the index to include the > -mm-dd portio

Re: [SQL] Date and filling issues

2008-03-20 Thread chester c young
> > A sample of the current results data would be like > datesales > 2008-03-07 100.00 > 2007-03-10 150.00 > 2007-03-18 50.00 > > and what I'm trying to do is fill in the missing dates with sales > values of 0. what I do is have a table called days t

Re: [SQL] Date and filling issues

2008-03-19 Thread Rodrigo E. De León Plicet
On 3/19/08, Christopher Crews <[EMAIL PROTECTED]> wrote: > and what I'm trying to do is fill in the missing dates with sales values of 0. create or replace function gen_dates(sd date, ed date) returns setof date as $$ select $1 + i from generate_series(0, $2 - $1) i; $$ language sql immutable; se

Re: [SQL] Date and filling issues

2008-03-19 Thread Osvaldo Kussama
2008/3/19, Christopher Crews <[EMAIL PROTECTED]>: > Hi All, > I'm not quite sure how to phrase this, but essentially my company has me > working on some reports and I have some charts associated with the SQL > results. > > My current query is: > > select > transaction_date as date, > sum(sa

Re: [SQL] date format

2008-01-25 Thread Frank Bax
iuri de araujo sampaio wrote: hi, how to change the default format for type date? I have created a field on a table: ## create table tbl_inventory ( item_id integer constraint c_pk primary key, I. purchase_date date, II. fabrication_date date, III. ex

Re: [SQL] date format

2008-01-24 Thread Scott Marlowe
Please keep replies on list. Others might have input that will help. On Jan 24, 2008 11:24 AM, iuri de araujo sampaio <[EMAIL PROTECTED]> wrote: > Yes, I am trying to insert the string ´2008 7 22´ as a date. > and i can´t change the input format. Is that a edit the default format > type date, in

Re: [SQL] date format

2008-01-24 Thread Scott Marlowe
On Jan 24, 2008 2:06 AM, iuri de araujo sampaio <[EMAIL PROTECTED]> wrote: > hi, > > how to change the default format for type date? > I have created a field on a table: > > ## > create table tbl_inventory ( > item_id integer constraint c_pk primary key, > I. purchase_date date

Re: [SQL] date format

2008-01-24 Thread Adrian Klaver
On Thursday 24 January 2008 12:06 am, iuri de araujo sampaio wrote: > hi, > > how to change the default format for type date? > I have created a field on a table: > > ## > create table tbl_inventory ( > item_id integer constraint c_pk primary key, > I. purchase_date date, >

Re: [SQL] date format

2008-01-24 Thread A. Kretschmer
am Thu, dem 24.01.2008, um 5:06:58 -0300 mailte iuri de araujo sampaio folgendes: > hi, > > how to change the default format for type date? You can change datestyle, a simple example: test=# select '30.12.2007'::date; ERROR: date/time field value out of range: "30.12.2007" HINT: Perhaps you

Re: [SQL] date problems

2007-08-30 Thread Roberto Spier
ivan marchesini escreveu: Dear PG users, I have an access db and I'm trying to pass all to postgres I have used mdbtools to export the schema and all went quite well. then I exported the single tables... to csv.. a lot of table have some timestamp fields containing data as DD/MM/, and I'm no

Re: [SQL] date problems

2007-08-30 Thread Michael Glaesemann
On Aug 30, 2007, at 8:01 , ivan marchesini wrote: a lot of table have some timestamp fields containing data as DD/MM/ , and I'm no able to copy this table into postgres... because it needs /MM/DD... I used \copy... The input and output formats of dates is controlled by the datestyle

Re: [SQL] date problems

2007-08-30 Thread A. Kretschmer
am Thu, dem 30.08.2007, um 15:01:03 +0200 mailte ivan marchesini folgendes: > Dear PG users, > I have an access db and I'm trying to pass all to postgres > I have used mdbtools to export the schema and all went quite well. > then I exported the single tables... to csv.. > > a lot of table have so

Re: [SQL] date arithmetic

2006-08-10 Thread Osvaldo Rosario Kussama
chrisj escreveu: Hi ALL, I want to do date arithmetic in SQL with a column that is integer. example create table bob ( col1 timestamp , col2 int4 ; where col2 represents a number of minutes. I want to do something like select col1 + interval col2 minutes from bob This is doable wi

Re: [SQL] Date ranges + DOW select question

2006-06-22 Thread Aaron Bono
I am a little confused.  Where are you casting dateStart and dateEnd?  I don't see either in your query.  I assume dayOfWeek is a number between 0 and 6, or maybe not?A little more detail would help.Thanks, Aaron BonoOn 6/15/06, joseppi c <[EMAIL PROTECTED]> wrote: Hi,I have a table which contains

Re: [SQL] date array

2006-04-24 Thread A. R. Van Hook
While down loading 8.1.3, I tried the following: update pf_inspectionsBld set insdate[0] = current_date update pf_inspectionsBld set insdate[1] = current_date update pf_inspectionsBld set insdate[2] = current_date update pf_inspectionsBld set insdate[3] = current_date update pf_inspectionsBld set

Re: [SQL] date array

2006-04-23 Thread Bruno Wolff III
Please keep responses copied to the list. This both helps other people with similar questions by getting the discussion in the archives and helps you by letting other people see your additional questions. On Sun, Apr 23, 2006 at 13:21:49 -0500, "A. R. Van Hook" <[EMAIL PROTECTED]> wrote: > I am

Re: [SQL] date array

2006-04-23 Thread Bruno Wolff III
On Sun, Apr 23, 2006 at 07:55:54 -0500, "A. R. Van Hook" <[EMAIL PROTECTED]> wrote: > How do you add null values to a date array? > > update dattable set insDate= '{04/12/2006,null}' <-- doesn't work That is the correct format. However, I think that only works in HEAD (what will become 8.2

Re: [SQL] date

2006-02-10 Thread Osvaldo Rosário Kussama
superboy143 (sent by Nabble.com) wrote: Hello, How can I write an sql query in postgresql so that I can insert a date into a table in the format DD-MM-, and when I select the date from the table I should get the date in the same format. See postgresql.conf documentation (http://www.pos

Re: [SQL] date

2006-02-10 Thread Tom Lane
Ken Hill <[EMAIL PROTECTED]> writes: > On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote: >> You can't define the format in the db, but you can define the >> output-format with to_char(date, 'DD-MM-'); > You could also try using the data_part() function: Setting the DateStyle parameter m

Re: [SQL] date

2006-02-10 Thread Ken Hill
On Fri, 2006-02-10 at 07:38 +0100, A. Kretschmer wrote: am 09.02.2006, um 22:18:09 -0800 mailte superboy143 (sent by Nabble.com) folgendes: > > Hello, > > How can I write an sql query in postgresql so that I can insert a date into > a table in the format DD-MM-, and when I select the d

Re: [SQL] date

2006-02-09 Thread A. Kretschmer
am 09.02.2006, um 22:18:09 -0800 mailte superboy143 (sent by Nabble.com) folgendes: > > Hello, > > How can I write an sql query in postgresql so that I can insert a date into > a table in the format DD-MM-, and when I select the date from the table > I should get the date in the same format

Re: [SQL] Date Interval

2005-12-06 Thread Magdalena Komorowska
It works great, very nice method :-) thanks a lot! MK ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Date Interval

2005-12-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Bruce Momjian writes: > Magdalena Komorowska wrote: >> Hi, >> I hale a problem with counting interwal and I can't find what to do with >> this. >> I have two fields in the table: >> Column | Type | Modifiers >> -+-+--- >> d

Re: [SQL] Date Interval

2005-12-06 Thread Michael Fuhr
On Tue, Dec 06, 2005 at 11:54:05AM -0500, Bruce Momjian wrote: > test=> SELECT current_timestamp + cast(x || ' months' AS INTERVAL) FROM > test; >?column? > --- > 2006-03-06 11:53:05.574279-05 > (1 row) Or another way: test=> CREATE TABLE test (x numeric);

Re: [SQL] Date Interval

2005-12-06 Thread Bruce Momjian
Magdalena Komorowska wrote: > Hi, > I hale a problem with counting interwal and I can't find what to do with > this. > I have two fields in the table: > Column | Type | Modifiers > -+-+--- > date_in | date| > interwal_months | numeric | >

Re: [SQL] date question

2005-11-03 Thread Michael Glaesemann
On Nov 4, 2005, at 1:17 , Judith Altamirano Figueroa wrote: Hi everybody, in Postgres 7.0.2 I have the next query: SELECT * from clientes_proceso where fecha_mod::date <= now() -1; but in version 8.0.1 returns the next error: ERROR: The operator doesn't exist: timestamp with time zone - inte

Re: [SQL] date question

2005-11-03 Thread lucas
Quoting Judith Altamirano Figueroa <[EMAIL PROTECTED]>: Hi everybody, in Postgres 7.0.2 I have the next query: SELECT * from clientes_proceso where fecha_mod::date <= now() -1; but in version 8.0.1 returns the next error: ERROR: The operator doesn't exist: timestamp with time zone - integer How c

Re: [SQL] Date/Time Conversion

2005-04-10 Thread Yasir Malik
beta_jgw=# update scenario1.time_test set local_hour = extract(hour from to_timestamp(to_char(gmt_date,'-MM-DD')||' '||to_char(gmt_hour,'99')||':00:00-00','-MM-DD HH24:MI:SS') at time zone 'EST'); Wild guess, but shouldn't that be :00:00:00? Regards, Yasir

Re: [SQL] Date/Time Conversion

2005-04-03 Thread Greg Stark
James G Wilkinson <[EMAIL PROTECTED]> writes: > I hope that this is some silly beginner's mistake. I have spent quite a bit > of > time > reading the PostgreSQL documentation and cannot find my error. I have also > scanned the PostgreSQL archive and the web for help, but I have not found > anyt

Re: [SQL] Date/Time Conversion

2005-04-03 Thread Yasir Malik
beta_jgw=# update scenario1.time_test set local_hour = extract(hour from to_timestamp(to_char(gmt_date,'-MM-DD')||' '||to_char(gmt_hour,'99')||':00:00-00','-MM-DD HH24:MI:SS') at time zone 'EST'); This sounds like a stupid answer, but shouldn't that be :00:00:00?

Re: [SQL] Date/Time Conversion

2005-04-02 Thread Tom Lane
James G Wilkinson <[EMAIL PROTECTED]> writes: > beta_jgw=# update scenario1.time_test set local_day = extract(day from > to_timestamp(to_char(gmt_date,'-MM-DD')||' > '||to_char(gmt_hour,'99')||':00:00-00','-MM-DD HH24:MI:SS') at time > zone 'EST'); That seems like a mighty ugly way to d

Re: [SQL] date subtraction

2005-03-21 Thread Richard Huxton
Ashok Agrawal wrote: I need to do date calculation similar to oracle in postgres. like sysdate - creation_date of the record which returns no of days in oracle which you can convert to hours or second by multiplying by 60 or 3600. How do i achieve this in postgres. Umm, SELECT CURRENT_DATE - crea

Re: [SQL] date - date returns integer?

2005-03-04 Thread Tom Lane
Andrew Hammond <[EMAIL PROTECTED]> writes: > Should date - date return type integer, not interval? If we made it return interval then there would be all sorts of timezone dependencies introduced (think about DST crossings) ... which is generally something you don't want to think about when doing d

Re: [SQL] date - date returns integer?

2005-03-04 Thread Bruno Wolff III
On Fri, Mar 04, 2005 at 15:59:02 -0500, Andrew Hammond <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Should date - date return type integer, not interval? Yes. This is in the documentation. ---(end of broadcast)

Re: [SQL] Date datatype

2004-12-21 Thread Iain
t; <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, December 21, 2004 5:38 PM Subject: Re: [SQL] Date datatype O Pablo Digonzelli έγραψε στις Dec 20, 2004 : hi all, Ca anyone send me an example how to update a date datatype? for example update table set birthdate = "200-

Re: [SQL] Date datatype

2004-12-21 Thread Achilleus Mantzios
O Pablo Digonzelli έγραψε στις Dec 20, 2004 : > hi all, > Ca anyone send me an example how to update a date datatype? > for example > update table set birthdate = "200-01-01" doesnt work. # update table set birthdate = '2000-01-01'; > > TIA > Pablo > > > ---(end of

Re: [SQL] Date datatype

2004-12-20 Thread Freemail
Hi, I think the problem is the double quote you use. Try a single quote e.g.: update yourtable set birthdate='200-01-01' where ... This man must be a very old one... :) I tried it using timestamp not date, but I think it should work as well. bye, -- cs. -Original Message- From: [EMAIL

Re: [SQL] date format in 7.4

2004-06-05 Thread scott.marlowe
On Fri, 20 Feb 2004, Silke Trissl wrote: > Hi, > > I have an application where users can enter the date via a web interface. > > Recently I upgrated my PostgreSQL version from 7.3 to 7.4.1. > > On 7.3 I run several tests about the format of the date and found, > that Postgres accepts almost eve

Re: [SQL] date format in 7.4

2004-06-05 Thread Tom Lane
Silke Trissl <[EMAIL PROTECTED]> writes: > On 7.3 I run several tests about the format of the date and found, > that Postgres accepts almost everything. Today I found out, that 7.4.1 > only accepts dates in the format mm-dd-yy, It now requires the field order to be what DateStyle says it is. See

Re: [SQL] Date format problems

2004-06-03 Thread Richard Huxton
Mark Roberts wrote: Hi im using the function below to insert data into my db; im using now() to get the timestamptz, however when inserted in the db the format seems to vary, the majority of the time its in the required European style but does spontaniously change to various other type can anyone t

Re: [SQL] Date format problems

2004-06-03 Thread Stef
Tom Lane mentioned : => Check the manual about runtime => configuration settings and postmaster switches. I use this : export PGDATESTYLE= (=ISO,European) P.S. Is there something wrong with the date on the postgres mailing list machine? All my mail from the list arrives with a date of

Re: [SQL] date arithmetic over calender year boundaries

2004-04-28 Thread Bruno Wolff III
On Wed, Apr 28, 2004 at 16:12:34 +1200, Ray Jackson <[EMAIL PROTECTED]> wrote: > Hi, > > The following Postgres 7.1 query extracts aggregated data for an > arbitrary period within each year for sites in a table containing > 30 years of temperature data. It isn't completely clear what you want t

Re: [SQL] Date format issue

2004-03-18 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: > You didn't say what version you're using, but IIRC, there was a bug which > caused the above sort of behavior. I think it was fixed in 7.4 and could > be fixed in 7.3.x with a catalog change which you might be able to find in > the archives. Good memory

Re: [SQL] Date format issue

2004-03-17 Thread Stephan Szabo
On Thu, 18 Mar 2004, Raman wrote: > In my query of time zone i have details of interval with me like '-9:00', > '+5:30' etc > > my problem is regarding the format of Date which i receive... ie. when I add > the interval field the results are like: > Query: > select current_date at TIME ZONE "inter

Re: [SQL] Date / interval question

2004-02-20 Thread Gnugeek
I'm looking for a way, within SQL, given a starting date and an ending date, to get back the number of months between the start and end date. If I "SELECT end_date - start_date", I get back an interval in days; I need months. Thanks for any suggestions, Brian ---(end o

Re: [SQL] Date Foo.

2004-02-20 Thread scott.marlowe
I'm still not sure what you were looking for. If you have, say, March 16th, and the next date is August 23rd, do you want to count March, April, May, Jun, July, August = 6? Or do you want to count the number of 30 day periods? Using date_part gets you the first one. Plus, since months can be

Re: [SQL] Date Foo.

2004-02-20 Thread Brian Knox
Sorry, Not looking for a way to extract a month from a timestamp. I'm looking for a way to convert an interval from days to months. I'm not sure after digging into it that there is a way to handle it in SQL, as the interval that results from subtracting one timestamp from another is not away of

Re: [SQL] date format in 7.4

2004-02-20 Thread Richard Huxton
On Friday 20 February 2004 14:58, Silke Trissl wrote: > Hi, > > I have an application where users can enter the date via a web interface. > > Recently I upgrated my PostgreSQL version from 7.3 to 7.4.1. > > On 7.3 I run several tests about the format of the date and found, > that Postgres accepts a

Re: [SQL] Date format problems

2004-02-16 Thread Tom Lane
"Mark Roberts" <[EMAIL PROTECTED]> writes: > Sure, sorry; Im using postgres version 7.2.1, and the column data type > is 'timestamptz' > Data examples: > 13/02/04 12:35:27 appears in the column as 02/04/13 12:35:27, or > 13/04/02 12:35:27 > 70% of the time it is inserted in the correct format.

Re: [SQL] Date format problems

2004-02-16 Thread Mark Roberts
Sure, sorry; Im using postgres version 7.2.1, and the column data type is 'timestamptz' Data examples: 13/02/04 12:35:27 appears in the column as 02/04/13 12:35:27, or 13/04/02 12:35:27 70% of the time it is inserted in the correct format. The function shown in previous email is called by a C

Re: [SQL] Date format problems

2004-02-16 Thread Tom Lane
"Mark Roberts" <[EMAIL PROTECTED]> writes: > Hi im using the function below to insert data into my db; im using > now() to get the timestamptz, however when inserted in the db the format > seems to vary, the majority of the time its in the required European > style but does spontaniously change to

Re: [SQL] date function problem

2004-02-03 Thread Tomasz Myrta
Dnia 2004-02-03 16:51, Użytkownik [EMAIL PROTECTED] napisał: Hi All I have an expiration_date column in my table with data type as timestamp. I need to set that as one year after the current time. how do i do that. I am getting a casting problem whenever i try something. something like now()+ 1 yea

Re: [SQL] date function problem

2004-02-03 Thread Larry Rosenman
--On Tuesday, February 03, 2004 10:51:45 -0500 [EMAIL PROTECTED] wrote: Hi All I have an expiration_date column in my table with data type as timestamp. I need to set that as one year after the current time. how do i do that. I am getting a casting problem whenever i try something. something lik

Re: [SQL] Date select question...

2004-01-08 Thread Tom Lane
Lance Munslow <[EMAIL PROTECTED]> writes: > [ why do these act differently: ] > select * from test where test_date between '20041001' and '20041101'; > select * from test where test_date between 20041001 and 20041101; In the latter case the constants are integers, not dates. IMHO the best policy

Re: [SQL] Date interval

2003-09-25 Thread sad
On Friday 26 September 2003 09:18, you wrote: > I am looking for a way to convert an interval into a number of days ( > integer); > > In sybase I would use : > > days(today()-r_expire) SELECT now()::DATE - '1900-12-10'::DATE; ?column? 375

Re: [SQL] Date interval

2003-09-25 Thread Tomasz Myrta
I am looking for a way to convert an interval into a number of days ( integer); In sybase I would use : days(today()-r_expire) where r_expire is the timestamp I am comparing against. How do we do this in postgres? date_trunc(today()-r_expire) does not seem to do it select extract(epoch f

Re: [SQL] date calculation

2003-08-22 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > cast('1970-1-1' as timestamp)+cast(your_ticks || ' seconds' as interval) > Does anyone know better way to cast it? The above will probably give the wrong answer (off by your timezone offset). The reference point should be zero hour GMT, but the first ca

Re: [SQL] date calculation

2003-08-21 Thread Tomasz Myrta
Hi there, I have a problem calculating a date. A field carries the date as passed seconds since Jan 1st 1970. How can I get the date as dd.mm. out of this?? cast('1970-1-1' as timestamp)+cast(your_ticks || ' seconds' as interval) Does anyone know better way to cast it? Regards, Tomasz Myrta

Re: [SQL] date question

2003-06-22 Thread Bruno Wolff III
On Fri, Jun 20, 2003 at 19:33:35 +0200, javier garcia - CEBAS <[EMAIL PROTECTED]> wrote: > Hi all; > > Peter, thank you very much for your help. Just a little thing. I've done as > you say: > > CREATE TABLE rain_series_dated AS SELECT (year * interval '1 year' + month * > interval '1 month' +

Re: [SQL] date question

2003-06-21 Thread javier garcia - CEBAS
Hi all; Peter, thank you very much for your help. Just a little thing. I've done as you say: CREATE TABLE rain_series_dated AS SELECT (year * interval '1 year' + month * interval '1 month' + day * interval '1 day') AS fecha,est7237,est7238,est7239,est7250 FROM rain_series ORDER by fecha; I se

Re: [SQL] date question

2003-06-17 Thread Peter Eisentraut
javier garcia - CEBAS writes: > Is there a way to create a table from this table, directly in Postgres in > which a date field is created based in the values of "year", "month", "day" > in this table? year * interval '1 year' + month * interval '1 month' + day * interval '1 day' This results in

Re: [SQL] date question

2003-06-16 Thread Bruno Wolff III
On Fri, Jun 13, 2003 at 13:44:09 +0200, javier garcia - CEBAS <[EMAIL PROTECTED]> wrote: > > And I've got another related tables with a date field. I need to compare the > dates field in the other tables with "year", "month", "day" in this table. > > Is there a way to create a table from this

Re: [SQL] Date trunc in UTC

2002-12-03 Thread Thrasher
Hi all Finally, I am using a plpgsql procedure that accomplish that in PostgreSQL 7.2.1. The code follows: CREATE OR REPLACE FUNCTION utc_date_trunc (TEXT, TIMESTAMP) RETURNS TIMESTAMP AS ' DECLARE utcts TIMESTAMP WITHOUT TIME ZONE; utcdt TIMESTAMP WITHOUT TIME ZONE; BEGIN --> First get

Re: [SQL] Date trunc in UTC

2002-11-26 Thread Juan Fernandez
Hi Richard Ok, I'll do my best to explain clearer ;) I have to make some monthly reports about some service requests activity. So, I'm keeping in a table the monthly traffic. TABLE traffic +-+++ | service | month | visits | +-+---

Re: [SQL] Date trunc in UTC

2002-11-22 Thread Tom Lane
Thrasher <[EMAIL PROTECTED]> writes: > The biggest point that I see is that it would be nice to have some kind > of function that works with UTC values, regarding of which timezone the > user has set. You can do that in 7.3, using the AT TIME ZONE construct. Observe: regression-# begin; BEGIN

Re: [SQL] Date trunc in UTC

2002-11-22 Thread Thrasher
The biggest point that I see is that it would be nice to have some kind of function that works with UTC values, regarding of which timezone the user has set. Let's say, something like SELECT UTC_DATE_TRUNC ('month', NOW ()); utc_date_trunc 2002-11-01 01:00:00+01

Re: [SQL] Date trunc in UTC

2002-11-21 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Hmm - good point. You can revert to the client default but not to the > previous value. I don't know of any way to read these SET values > either - a quick poke through pg_proc didn't show anything likely. In 7.3 you can use current_setting() and set_co

Re: [SQL] Date trunc in UTC

2002-11-21 Thread Richard Huxton
On Wednesday 20 Nov 2002 3:40 pm, Juan Fernandez wrote: > Hi Richard > > Ok, I'll do my best to explain clearer ;) I'll do my best to be of some use ;-) > I have to make some monthly reports about some service requests > activity. So, I'm keeping in a table the monthly traffic. > > TABLE traffic

Re: [SQL] Date trunc in UTC

2002-11-20 Thread Richard Huxton
On Wednesday 20 Nov 2002 10:37 am, Thrasher wrote: > No I cannot use SET TIME ZONE. > > SET TIME ZONE will be set by any client backend. But what I want to get > is that DATE_TRUNC('month', ) = DATE_TRUNC('month', > ). Sorry, I've obviously misunderstood. Are you just looking to discard the timez

Re: [SQL] Date trunc in UTC

2002-11-20 Thread Thrasher
No I cannot use SET TIME ZONE. SET TIME ZONE will be set by any client backend. But what I want to get is that DATE_TRUNC('month', ) = DATE_TRUNC('month', ). Richard Huxton wrote: On Wednesday 20 Nov 2002 9:44 am, Thrasher wrote: Hi I do not know if it's an error, but in this query =# sel

Re: [SQL] Date trunc in UTC

2002-11-20 Thread Richard Huxton
On Wednesday 20 Nov 2002 9:44 am, Thrasher wrote: > Hi > > I do not know if it's an error, but in this query > > =# select date_trunc ('month', now ()); > date_trunc > > 2002-11-01 00:00:00+01 > (1 row) > > I've got the truncated date dependant to my timezone. > >

Re: [SQL] DATE TIME INDEX ?

2002-11-16 Thread Tom Lane
PostgreSQL Server <[EMAIL PROTECTED]> writes: > I found that the only way to force postgres to use index is: > explain select id,datarx::date from docs where datarx between '2002-11-13' and >'2002-11-14' ; > Index Scan using idx_documenti_datarx on documenti (cost=0.00..7.86 rows=2 width=12) G

Re: [SQL] date

2002-10-18 Thread Tom Lane
"wishy wishy" <[EMAIL PROTECTED]> writes: > we have a PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC 2.96 > installation on pogo linux 7.2 > we are facing a data problem when we do the following > select to_char(to_date('1969-10-22','-MM-DD'),'-MM-DD'); > ERROR: Unable to convert

Re: [SQL] date

2002-10-18 Thread Jean-Luc Lachance
Try select to_char( '1969-10-22'::date, '-MM-DD'); wishy wishy wrote: > > hi folks, > we have a PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC 2.96 > installation on pogo linux 7.2 > we are facing a data problem when we do the following > select to_char(to_date('1969-10-22','-M

Re: [SQL] date

2002-10-18 Thread wishy wishy
hi folks, we have a PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC 2.96 installation on pogo linux 7.2 we are facing a data problem when we do the following select to_char(to_date('1969-10-22','-MM-DD'),'-MM-DD'); ERROR: Unable to convert date to tm we have been trying to find a

Re: [SQL] Date/Time types

2002-09-27 Thread Josh Berkus
Seb, > I'm french, so excuse me if my english is not correct. Whereas if you were a native English speaker, you would realize that there is no such thing as "correct English" > I'd like to create a table with a Timestamp row (named date for > example) and > width a resolution as smaller a

Re: [SQL] Date: the day before yesterday.

2001-08-14 Thread Jan Wieck
Jason wrote: > I am trying to retrieve records generated in the passed two days and > encountered difficulties in dealing with the date in Oracle. > Here is the query I try to form: > > select * from Table where InputDate>=[the day before yesterday] > > I tried "sysdate-2", didn't work. > Any sugg

Re: [SQL] Date Time Functions - ANSI SQL ?

2001-07-30 Thread Gonzo Rock
At 01:39 AM 7/30/01 -0400, Tom Lane wrote: >Gonzo Rock <[EMAIL PROTECTED]> writes: >> Are all the date time functions described in the pgSQL docs are >> ANSI-SQL or pgSQL extensions? > >One or the other, yes ;-) Hey Tom, You Clever guy! Yes, One or the other! OK OK! Nothing worse than a progra

Re: [SQL] Date Time Functions - ANSI SQL ?

2001-07-29 Thread Tom Lane
Gonzo Rock <[EMAIL PROTECTED]> writes: > Are all the date time functions described in the pgSQL docs are > ANSI-SQL or pgSQL extensions? One or the other, yes ;-) EXTRACT() is ANSI, though I think we may accept a few more field keywords than the spec mentions. regards, t

Re: [SQL] Date Validation?

2001-07-14 Thread Christopher Sawtell
On Sun, 15 Jul 2001 06:40, Josh Berkus wrote: > Richard, > > > Poked around and had a think and can't come up with anything better > > than > > Stephan Szabo's suggestion of hacking PG's built-in function. You'll > > want > > to_timestamp() which is called from to_date and it's in > > src/backend/

  1   2   >