Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 3rd, 2006, 3:55 PM   #1
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Querying database - help

Hi there people...

I have the following table in my database

activity (activityID, userID, time, page)

It keeps track of which page the users have visited and when, a bit like big brother i guess.

I have just finished a view activity script, where the user enters the name of a user and the script outputs the activity of the user specified.

However, if the user has been busy, this can be many (100's) of rows of data. I need to allow the user to search a specified date range, i.e. 15 January 2005 - 15 January 2006.

How can i do this???

The date is stored as;
Friday 24th of February 2006 05:24:39 PM

Any suggestion???

Regards pps
k4pil is offline   Reply With Quote
Old Mar 3rd, 2006, 4:05 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Make sure that your date-time is stored in the DB in a manner that the DB construes as a date-time, then just build a query according to their rules.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 6th, 2006, 7:17 AM   #3
guess
Programmer
 
Join Date: Feb 2006
Posts: 40
Rep Power: 0 guess is on a distinguished road
I have just done that kind of script searching a database by means of day and many more.U must format ur text according to the information in the database or vice-versa.
No matter which programming language u use,there must be a date function which is getting date according to a given format.U can also find their formatting usage...
guess is offline   Reply With Quote
Old Mar 6th, 2006, 8:29 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by k4pil
How can i do this???
What database software are you using?
Arevos is offline   Reply With Quote
Old Mar 6th, 2006, 11:51 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by k4pil
The date is stored as;
Friday 24th of February 2006 05:24:39 PM
Have you stored the date as a TEXT/VARCHAR or as a DATETIME/TIMESTAMP? The former will not allow comparisons; it's a string, nothing more. The latter will allow you to compare it to other dates in SQL. Most databases will be able to parse the following data:
2006-02-24 17:24:39
That's YYYY-MM-DD HH:mm:ss. Check your database - if the column is storing it as an actual date/time, not a string, you can compare it using the following SQL statement:
SELECT `time` FROM `activity` WHERE `time` >= '2005-01-15' AND `time` <= '2006-01-15' ORDER BY `time` ASC
To help more, we'll need to know what database software you're using.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 9th, 2006, 1:11 PM   #6
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
I'v managed to fix it.

My stupid self had stored the date as a string - changed it to time stamp and some time later - its working fine now!

thanks!!
k4pil is offline   Reply With Quote
Old Mar 9th, 2006, 5:01 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Congrats.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:36 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC