If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Days between

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-22-07, 07:07
xixo xixo is offline
Registered User
 
Join Date: May 2004
Posts: 78
Days between

Hi,

I have a table with events, wich have a begin date and a end date. And now I have to point this dates in a calendar. If the events are a day only, no problem and I point that day.
The problem is when the begin and end dates have more than a day between then. How can I have a select that gives me all the days in between so that I can point them in the calendar.

Maby thanks.
Reply With Quote
  #2 (permalink)  
Old 02-22-07, 13:39
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
what you need to do is create a second table with a column for dates. It should include a row for each day of the year.

You would then do a LEFT OUTER JOIN on this table and your current one and it would print out all the days in between your necessary start/end dates.
Reply With Quote
  #3 (permalink)  
Old 02-23-07, 07:30
xixo xixo is offline
Registered User
 
Join Date: May 2004
Posts: 78
I don't think that should resolve my problem, because I don't have a day to OUTER JOIN.

I have something like this:

SELECT * from events;

event_id text begin_dt end_dt
-------- ---- -------- -------
15 xpto 2007-01-15 2007-01-25

And I would like to have a result like this:

event_id day month year
-------- ---- ------ ----
15 15 01 2007
15 16 01 2007
.
.
15 24 01 2007
15 25 01 2007

thanks.

Last edited by xixo; 02-23-07 at 07:56.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On