Received: from smtp012.mail.yahoo.com (smtp012.mail.yahoo.com [216.136.173.32]) by postgresql.org (8.11.3/8.11.1) with SMTP id f6BHuVa89984 for ; Wed, 11 Jul 2001 13:56:31 -0400 (EDT) (envelope-from chrup999@yahoo.com) Received: from proxy.compucom.com (HELO Z161842) (204.214.145.2) by smtp.mail.vip.sc5.yahoo.com with SMTP; 11 Jul 2001 17:56:29 -0000 X-Apparently-From: Message-ID: <006a01c10a32$cf3cdec0$5dd26383@corp.compucom.com> From: "Chris Ruprecht" To: "p-php" References: <002101c10a12$bea29660$5dd26383@corp.compucom.com> <000d01c10a28$13ac67c0$1a0d040a@Mitch> Subject: Re: Date Manipulations Date: Wed, 11 Jul 2001 12:56:28 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200107/13 X-Sequence-Number: 470 Well, what I was trying to do was this: I need to insert records into a rate table. The table has start and end dates (fdate, tdate) and there are no gaps in the dates allowable. We have things like 4/1/2001 - 4/15/2001, the next record _MUST_ have 4/16/2001 as a start date ... and so on. The last record has 12/31/2999 as an end date (meaning forever, until the Y3K bug hits, but I don't plan to be in the programming business by then). When I insert a record, I have to find at least one other record, either to determine what my new end date should be (when I insert it before the first record) or, I need to adjust the end date of an existing record to one day before my new record's start date. I do this by: $OldDate = pg_result( $FindOldRate, 0, 4 ); and update ... set rate.tdate = ('$NewDate'::date - 1)::date ... What I found is that I also need to do: Insert ... values( ('$NewDate'::date + 0)::date ... the + 0 (as in ZERO) gets me - if I do it this way, it works, if I leave it off, it complains that it has a bad external representation (or something like that). But the field has the format "YYYY-MM-DD" ... it just has me puzzled ... I can manage with the work-around, I just don't understand why, and I would like to know why (even if this knowledge serves no purpose ;-). Best regards, Chris ----- Original Message ----- From: "Mitch Vincent" To: "Chris Ruprecht" ; "p-php" Sent: Wednesday, July 11, 2001 11:39 AM Subject: Re: [PHP] Date Manipulations > Well, it depends on what you're trying to do :-) > > You can add days an arbitrary date in a number of ways , I often let PG > handle it though (as you are).. > > I generally do something like > > SELECT ('05-05-2001'::date + '5 days'::interval) > > Or something like that if I need X days ahead or behind date Y... > > ----- Original Message ----- > From: "Chris Ruprecht" > To: "p-php" > Sent: Wednesday, July 11, 2001 10:06 AM > Subject: [PHP] Date Manipulations > > > > Hi all, > > > > Currently, when working with dates, I use constructs like > > > > ('$NewDate'::date + 5)::date > > > > this seems a little clumsy to me and I was wondering if there was an > easier > > way of doing this. > > > > Best regards, > > Chris > > > > > > > > _________________________________________________________ > > Do You Yahoo!? > > Get your free @yahoo.com address at http://mail.yahoo.com > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com