dates not filtering

RSXchin

Well-known Member
Joined
Oct 23, 2010
Messages
758
I have a field called HistoryTimestamp that is a date column and has dates written like "7/20/2011 7:00:00 AM" (2 spaces)

I tried
Code:
Select * from HistoryTable
WHERE HistoryTimestamp > 7/20/2011

But that returns ALL records. any suggestions?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
That's because dates are stored in Access/Excel as the number or days since 1/1/1900.

And 7/20/2011, as you have written it, means "7 divided by 20 divided by 2011", which will be some very small fraction less than one, so all days after 1/1/1900 will be returned.

To indicate dates in Access, you need to surround them by the pound sign, i.e.
WHERE HistoryTimestamp > #7/20/2011#
 
Upvote 0
If you leave the time component off of your date, it defaults to midnight (12:00 AM). So one way is to do it like this:

WHERE HistoryTimestamp BETWEEN #7/20/2011# AND #7/21/2011#
 
Upvote 0
RSXchin

So you managed to get the data into Access?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,854
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top