Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MSQuery

Author  Topic 

j_Southern
Starting Member

2 Posts

Posted - 2014-12-15 : 05:20:00
I use an ODBC link to download from a Sage accounting package into Excel.
I use the MSQuery "grid" to enter in my queries and I have recently had difficulties, not encountered before, when I have needed to use a clause limiting data to after a given date
[ The SQL should say something like WHERE WM_ORDERS.INVOICE_DATE > #30/11/2013#] I think I used to be careless in how I entered the date because MSQuery would add the hashes and correct the date format. Now, however I enter the date, I get an error message telling me there is a syntax error in the date.

I would like some help please with what the correct syntax for a date in MSQuery should be, and if possible what other areas might be impacting on my problem.


John

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-12-15 : 05:33:44
in sql server you can add a date filter by using single quotes to the value.
for example where invoicedate='30112013'

Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95
Go to Top of Page

j_Southern
Starting Member

2 Posts

Posted - 2014-12-15 : 07:34:22
Thanks for your interest but no this does not work in MSQuery. I think I will have to write the SQL as a string in VBA. I know that works.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-12-22 : 07:13:31
Also use unambigious date format in SQL Server
where invoicedate='20131130'

For more information refer this http://beyondrelational.com/modules/2/blogs/70/posts/10898/understanding-datetime-column-part-ii.aspx


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -