February 3, 2011 at 12:15 pm
Hi,
I'm trying to select records between two time periods. I have a Timestamp column and am using this query.
Select Total From tblGrid Where Station = 91 and (TimeStamp >='03/08/2010 6:50:00 PM' AND TimeStamp <= '04/08/2010 6:50:00 PM' )
For some reason it only gives results when I change the year to 2011. Not sure what's going on the timestamps are in this format.
03/08/2010 6:50:00 PM
February 3, 2011 at 12:24 pm
What data type is the timestamp column?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
February 3, 2011 at 12:35 pm
I just figured it out, I had to use this format
(TimeStamp >='2011-01-03 010:00:00' AND TimeStamp <='2011-01-03 012:00:00')
Thanks
February 3, 2011 at 12:50 pm
yasirbc (2/3/2011)
I just figured it out, I had to use this format(TimeStamp >='2011-01-03 010:00:00' AND TimeStamp <='2011-01-03 012:00:00')
I do prefer the "between" notation but that's just me 🙂
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.February 4, 2011 at 8:01 am
Do you want to return rows that within the upper minute? Your current query will not return rows like this: '2011-01-03 012:00:01'
You also didn't answer Gus' question? Is the data stored as one of the date data types, and if so, which one?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply