dbTalk Databases Forums  

Date Criteria not working right

comp.databases.ms-access comp.databases.ms-access


Discuss Date Criteria not working right in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mcolson
 
Posts: n/a

Default Date Criteria not working right - 02-17-2011 , 10:55 AM






I am trying to query a table for information after a date using the
following query. This is giving me ALL of the data from the table,
before and after.

SELECT dbo_GP_PumpDownDaily.DateTime, dbo_GP_PumpDownDaily.Location,
dbo_GP_PumpDownDaily.Pressure
FROM dbo_GP_PumpDownDaily
WHERE (((dbo_GP_PumpDownDaily.DateTime)>#2/2/2011#));

If I query for information before my date, it works fine. If I query
for information on my date, it includes all data up to and including
that point.

Reply With Quote
  #2  
Old   
mcolson
 
Posts: n/a

Default Re: Date Criteria not working right - 02-17-2011 , 11:23 AM






I was finally able to get it to work when I changed the format so it
goes yyyy/mm/dd. Any idea on why this would be?

SELECT Format([dbo_GP_PumpDownDaily]![DateTime],"yyyy/mm/dd") AS
[DateTime], dbo_GP_PumpDownDaily.Location,
dbo_GP_PumpDownDaily.Pressure
FROM dbo_GP_PumpDownDaily
WHERE (((Format([dbo_GP_PumpDownDaily]![DateTime],"yyyy/mm/
dd"))>Format(#12/25/2010#,"yyyy/mm/dd")));

Reply With Quote
  #3  
Old   
Salad
 
Posts: n/a

Default Re: Date Criteria not working right - 02-17-2011 , 12:32 PM



mcolson wrote:
Quote:
I was finally able to get it to work when I changed the format so it
goes yyyy/mm/dd. Any idea on why this would be?

SELECT Format([dbo_GP_PumpDownDaily]![DateTime],"yyyy/mm/dd") AS
[DateTime], dbo_GP_PumpDownDaily.Location,
dbo_GP_PumpDownDaily.Pressure
FROM dbo_GP_PumpDownDaily
WHERE (((Format([dbo_GP_PumpDownDaily]![DateTime],"yyyy/mm/
dd"))>Format(#12/25/2010#,"yyyy/mm/dd")));

You probably have a Now() type field. A date field has a time of
0:00am. If your field has both date & time, they'll all most likely
have a time greater than 0:00am.

So
FldDate > #12/25/2010# And fldDate < #12/26/2010# would
get all records on 12/25. If you had
FldDate = #12/25/2010#
and the field was date & time, you'd end up with no records.

Reply With Quote
Reply




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.