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

[SQL] date arithmetic with columns

2012-03-03 Thread Peter Faulks
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. I am migrating from Firebird. One of the queries uses the dateadd function to build

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 > ---+-+-

[SQL] date range to set of dates expansion

2012-01-18 Thread Gary Stainburn
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 ---+-+ aid

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|

[SQL] Date comparison, user defined operators and magic

2010-02-26 Thread Petru Ghita
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello everybody, I was missing a comparison operator for DATE so I wrote one after a really fast look into the documentation. Working with version 8.4. create or replace function vav_date_posterior(date, date) RETURNS boolean AS $$ - -- return TRUE i

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

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

2009-10-22 Thread the6campbells
Why is Postgres returning a timestamp instead of the expected date data type for the first expression (the second returns a date)? In other words, is this a known bug or is it design intent. The manuals did not seem to appear to say this is intentional behaviour but is not SQL standard. select da

[SQL] date range query help

2008-11-19 Thread novice
Hi, We have two tables. select * from mobile_custodian; custodian_id | user_id | issue_date | return_date | mobile_no --+-++-+- 4 | Ben | 2008-10-11 | 2008-10-13 | 09455225998 5 |Josh | 2008-10-15 |

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

[SQL] Date Index

2008-10-30 Thread Ryan Hansen
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 portion of the date, not the time. I figure this would be where the "expression" portion

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

[SQL] Date and filling issues

2008-03-19 Thread Christopher Crews
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(sale_amount) as sales from ej_transaction where transaction_date

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

[SQL] date format

2008-01-24 Thread iuri de araujo sampaio
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. expiration_date date ); ## the er

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

[SQL] date problems

2007-08-30 Thread ivan marchesini
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 able to copy this table int

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

[SQL] date arithmetic

2006-08-10 Thread chrisj
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 with most other RDBM

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

[SQL] Date ranges + DOW select question

2006-06-21 Thread joseppi c
Hi, I have a table which contains starttime, endtime and DOW; i.e. a weekly list of times for when a process must be started and ended. TABLE: cronTimes FIELDS: starttime, endtime, dayOfWeek I have another table which contains date ranges. TABLE: dateRanges FIELDS: dateStart, dateEnd I need to

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

[SQL] date array

2006-04-23 Thread A. R. Van Hook
How do you add null values to a date array? update dattable set insDate = '{04/12/2006,'null'}<-- doesn't work update dattable set insDate= '{04/12/2006,null}' <-- doesn't work update dattable set insDate= '{04/12/2006,''}' <-- doesn't work the table field is defined as insDate d

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

[SQL] date

2006-02-09 Thread superboy143 (sent by Nabble.com)
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. -- View this message in context: http://www.nabble.com/date-t1097526.html#a2865031 Sent from the

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 | >

[SQL] Date Interval

2005-12-06 Thread Magdalena Komorowska
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 | -+-+--- Query

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

[SQL] date question

2005-11-03 Thread Judith Altamirano Figueroa
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 can drop a day to now()??

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

[SQL] Date/Time Conversion

2005-04-02 Thread James G Wilkinson
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 anything to get me over the hump (it is probably out there, I

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

[SQL] date subtraction

2005-03-20 Thread Ashok Agrawal
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. Thanks Ashok ---(end of

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)

[SQL] date - date returns integer?

2005-03-04 Thread Andrew Hammond
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Should date - date return type integer, not interval? /* [EMAIL PROTECTED]:5432/test =# */ SELECT ('2005-03-04'::timestamp - '2005-01-01'::date)::interval; ~ interval - -- ~ 62 days (1 row) /* [EMAIL PROTECTED]:5432/test =# */ SELECT ('2005-03-0

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
om: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pablo Digonzelli Sent: Tuesday, December 21, 2004 12:41 AM To: [EMAIL PROTECTED] Subject: [SQL] Date datatype hi all, Ca anyone send me an example how to update a date datatype? for example update table set birthdate = "200-01-

[SQL] Date datatype

2004-12-20 Thread Pablo Digonzelli
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. TIA Pablo ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

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

[SQL] date arithmetic over calender year boundaries

2004-04-27 Thread Ray Jackson
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. topo=> \d longterm Table "longterm" Attribute | Type | Modifier ---+--+-- site

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

[SQL] Date format issue

2004-03-17 Thread Raman
Hello All... 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 "interval" '+5:30'; timezone

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

[SQL] date format in 7.4

2004-02-20 Thread Silke Trissl
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 everything. Today I found out, that 7.4.1 only accepts dates

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

[SQL] Date format problems

2004-02-16 Thread Mark Roberts
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 throw any light on t

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

[SQL] date function problem

2004-02-03 Thread mohan
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 year. Please let me know --mohan --

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

[SQL] Date select question...

2004-01-08 Thread Lance Munslow
I have the following table: Table "public.test" Column | Type | Modifiers ---+--+--- test_date | date | with the following data: test_date 2004-10-31 2004-11-01 (2 rows) Why does the query: select * from test where test_date between '20041001' and

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

  1   2   >