Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Query on Current Week
Old 03-16-2005, 08:08 PM Query on Current Week
Experienced Talker

Posts: 34
Trades: 0
I have a table called "Events" and there i have an attribute date
Does anyone know how to retrieve reconds related to the current week only?
cmakedonas is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-16-2005, 10:00 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Make sure to store your dates like this....

20040312000000 <----just example date.

This way you can do a query like this...

Code:
SELECT * FROM Events WHERE date BETWEEN 20040312000000 AND 20040312235959
Get the idea? I've never used it, just found this through google.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 10:17 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
cptn,

that is a datetimestamp. Your search is actually only searching one day. I do not think this is what he is after bud.

I will try and do a wee tutorial for you on stripping dates in the morning, but there are plenty of PHPers who do not need to go to bed just now - i.e. non British - and they might do it earlier.

Steve.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 03-16-2005, 10:46 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You could use the WEEK function, I suppose.

Code:
SELECT * FROM events WHERE WEEK( mydate ) = WEEK( CURDATE() )

Ever look at a word for a while and think, wow, that is a weird word? Week is a weird word! =D
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-17-2005, 04:38 AM
Experienced Talker

Posts: 34
Trades: 0
I dind't know that there is a WEEK function . Thisn is what i actually need.

Thank you
cmakedonas is offline
Reply With Quote
View Public Profile
 
Old 03-17-2005, 08:50 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Quote:
Originally Posted by Gaffer Sports
cptn,

that is a datetimestamp. Your search is actually only searching one day. I do not think this is what he is after bud.

I will try and do a wee tutorial for you on stripping dates in the morning, but there are plenty of PHPers who do not need to go to bed just now - i.e. non British - and they might do it earlier.

Steve.
I know that it was only a day. I was not trying to do it for him but give him a clue as to how to accomplish this so I just put whatever dates. However, as Chroder pointed out a function that even I did not know about, that appears as though it will accomplish this task much better.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-17-2005, 09:09 AM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
Yep, top marks to Chroder as it appears none of us knew about the Week function..
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Reply     « Reply to Query on Current Week
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18794 seconds with 12 queries