Jump to content

Selecting between dates using a join


OutOfInk
Go to solution Solved by mac_gyver,

Recommended Posts

Am i better off using a join or between statement and if possible please leave an example.

 

I want to retrieve the current 'round' from my database.  To do this i need to compare the current date and time to the 'gameround' table 'Date' and 'Time'.

 

This is an example of the database im trying to work which round it is;

 

CellID Round Home HODDS Away AODDS Ground Date Time status won lost
1 1 Collingwood 2.40 Fremantle 1.70 Etihad 2014-03-14 19:50:00 Lock None None
2 1 GWS Giants 15 Sydney 1.00 Skoda 2014-03-15 16:40:00 Lock None None
3 1 Gold Coast 2.50 Richmond 1.60 Metricon 2014-03-15 18:40:00 Lock None None

 

Thanks

Edited by mac_gyver
removed hosting control panel links in example data
Link to comment
Share on other sites

when you copy/paste the content from your database gui, it copies the links and image tags leading to your web hosting, which causes a pop-up authentication dialog box every time someone views your post. in the future, just copy/paste the necessary text.

Edited by mac_gyver
Link to comment
Share on other sites

  • Solution

the following will select the current Round number, if any. if you want to select the rows corresponding to that round number, you would use this as a sub-query in your main query -

SELECT Round, MIN(CONCAT(Date,' ',Time)) as start, MAX(CONCAT(Date,' ',Time)) as end FROM gameround GROUP BY Round HAVING NOW() BETWEEN start AND end

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.