MySQL Forums :: Newbie :: Date/Time Query


Advanced Search

Date/Time Query
Posted by: Aaron Ford ()
Date: April 09, 2009 08:08AM

Help Anybody...

Ok this is the deal:
I have a table full of CDRs(Call Detail Records). Up till now I've been able to run simple queries on startTime (20090201143028.222, charVar) looking for a date span:

startTime BETWEEN 20090201000000.000 AND 20090230999999.999

with no problem. Now I have to not only span dates but now I have to pull records for time span (between 1630 and 2200) each day. I'm trying to use DATE_FORMAT & TIME_FORMAT to get at the date and time portion of startTime but keep getting syntax errors:

SELECT
DATE_FORMAT (startTime, %Y%M%d) as sDate

I was hoping to do something like this:

SELECT
*
FROM
Table
WHERE
(startTime BETWEEN 20090101000000.000 AND 20090130000000.000)
AND
startTime (TIME_FORMAT(startTime, %T) BETWEEN 1430000.000 AND 160000.000

I know that last line of code won't work... just trying to give a better idea of what I'm attempting to do...


Question:

Is it possible to pull the Date span and time span for each day using MySQL? Or would it be easier to do say (of which I'm fairly new at)... (.NET C#, database connection type programming thing)?

Thanks

Options: ReplyQuote


Subject Written By Posted
Date/Time Query Aaron Ford 04/09/2009 08:08AM
Re: Date/Time Query Guelphdad Lake 04/09/2009 08:25AM
Re: Date/Time Query A Ford 04/09/2009 08:31AM
Re: Date/Time Query Mark Snyder 04/09/2009 09:14AM
Re: Date/Time Query A Ford 04/09/2009 11:14AM
Re: Date/Time Query Rick James 04/11/2009 10:32PM
Re: Date/Time Query A Ford 04/13/2009 01:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.