Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
how to get 3 or more connected dates
Old
  (#1)
Guest
Guest
 
Posts: n/a
Default how to get 3 or more connected dates - 06-04-2007, 07:58 AM

PHP Version 4.3.10
MySQL: 4.1.10a

Let's say I have a table "Delivery" with a column 'Date'.
I had delivery's on 2007-05-01, 2007-05-02, 2007-05-08, 2007-05-15,
2007-05-16, 2007-05-17, 2007-05-30

How can I get all deliveries which:
differ 1 day from each other and where there are 3 connected
deliveries.

In this example it would result in
2007-05-15, 2007-05-16, 2007-05-17

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: how to get 3 or more connected dates
Old
  (#2)
Captain Paralytic
Guest
 
Posts: n/a
Default Re: how to get 3 or more connected dates - 06-04-2007, 07:58 AM

On 22 May, 13:19, cvsc...@gmail.com wrote:
> PHP Version 4.3.10
> MySQL: 4.1.10a
>
> Let's say I have a table "Delivery" with a column 'Date'.
> I had delivery's on 2007-05-01, 2007-05-02, 2007-05-08, 2007-05-15,
> 2007-05-16, 2007-05-17, 2007-05-30
>
> How can I get all deliveries which:
> differ 1 day from each other and where there are 3 connected
> deliveries.
>
> In this example it would result in
> 2007-05-15, 2007-05-16, 2007-05-17


What makes a delivery "connected"?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: how to get 3 or more connected dates
Old
  (#3)
lark
Guest
 
Posts: n/a
Default Re: how to get 3 or more connected dates - 06-04-2007, 07:58 AM

EMAIL REMOVED wrote:
> PHP Version 4.3.10
> MySQL: 4.1.10a
>
> Let's say I have a table "Delivery" with a column 'Date'.
> I had delivery's on 2007-05-01, 2007-05-02, 2007-05-08, 2007-05-15,
> 2007-05-16, 2007-05-17, 2007-05-30
>
> How can I get all deliveries which:
> differ 1 day from each other and where there are 3 connected
> deliveries.
>
> In this example it would result in
> 2007-05-15, 2007-05-16, 2007-05-17
>

J.O.Aho just answered this question:

One of the following should do what you need:

PERIOD_ADD(P,N)
ADDDATE(date,INTERVAL expr unit)
ADDDATE(expr,days)

http://dev.mysql.com/doc/refman/5.0/...ion_period-add

use one of these in your predicate.

--
lark -- EMAIL REMOVED
To reply to me directly, delete "despam".
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top