Question:
How to compare dates in the WHERE clause of an SQL used in Excel VBA accessing MS Project File with OLE DB?
Meipporul
2006-08-10 00:31:56 UTC
In Excel VBA, I am accessing a Microsoft Project 2003 file as a DB through MS OLE DB provider (Microsoft.Project.OLEDB.11.0). When I shoot an SQL to this which uses string comparisons in the WHERE clause like, TaskName='Coding', it works. But when I compare dates in the WHERE clause, like TaskStart > '07/08/06' or TaskStart > 07/08/06 or TaskStart>#07/08/06#, it does not work. Please let me know how to code the WHERE clause when comparing dates.
Five answers:
© 2007. Sammy Z.
2006-08-14 18:43:36 UTC
Are you sure you are formatting the date properly, and the task_start field is the correct datatype?



Write yourself a query without a filter on the task_start field that returns the task_start value in the result-set, so you can copy/paste that value (as an example of the format) into another SQL query, where you modify the sample-date to match your filter-by date.
?
2016-11-12 13:10:15 UTC
Vba Compare Dates
Bruno
2006-08-10 03:58:31 UTC
try to convert them to unix timestamp format (number of seconds from January 1st, 1970). there should be a function that does this for you (and back from it). then the comparison is easy, you just compare integers, and you can easily do date manipulations (ie 1 day = 86400 seconds)
weida
2006-08-12 05:32:24 UTC
You may use the access query tool "Advanced Access Builder" at http://www.download5000.com/page25449.aspx , it allows you to visually build complete SQL scripts.
anonymous
2006-08-10 06:39:34 UTC
I am a database development programer, you use some tools and learn sql(struct query language ). You can get one tool of Advanced SQL Builder at http://www.dlkj.net/sqlBuilder/ . My email is ymx@hdrj.net. OK?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...