|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SQL statement with multiple WHERE statementsI have a MS Access table with the fields, ID, ATime, and ADate and I want to
select records between a certain date and time. Will someone show me the proper syntax for the SQL statement. I need to construct the sql statement in VB.NET 2005. I can write one that pulls records between a set of dates, but not a certain time on the start date and a certain time on the endDate. Thanks Thomas -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access Any particular reason you have your timestamp separated into the two
fields Atime and ADate? I generally prefer to have a single datetime field that combines both as it makes querying much easier--something like this: SELECT * FROM MyTable WHERE ADateTime BETWEEN "2005-07-01 12:34:56" AND "2005-07-07 17:18:19" If you need to show only the date or only the time you can use DATEPART function or format fucntion in your application. If for some unfathomable reason you must keep the date and time separate it gets more complicated. You have to do something like this: SELECT * FROM MyTable WHERE (ADate = "2005-07-01" AND ATime > "12:34:56") OR (ADate > "2005-07-01" AND ADate < "2005-07-07" OR (ADate = "2005-07-07" AND ATime < "17:18:19") This will do what you want but is more complicated. Unless you have a really really good reason to keep the fields separate then I suggest using a field with both Date and Time combined. will NOT work because every day in the middle will be *** Sent via Developersdex http://www.developersdex.com *** The two being in separate fields is not under my control.
Thanks, Thomas -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Other interesting topics
Q:Multithreaded ADO.Net Connections Are Non Pooled?
Update ado.net DataSet referential integrity sqlDataAdapters/ NTAUTHORITY\NET SERVICE not authorized really daring subject! DataGrid MyBase.OnPaint -> content Question regarding OOP and database access rowfilter not working correctly Intellisense How to filter a Dataset and save it into Xml ? |
|||||||||||||||||||||||