I am using Excel to make an SQL query (connecting to an ODBC). I have a problem with the function DateAdd(), which just doesn't work as expected.
What I need to do is to get the data from the last six months.
My code is something like
SELECT blablabla FROM blablabla and then I have this:
WHERE Note_0.Relate_key = Work_history_0.WO_Key AND Work_history_0.Order_date> DateAdd(Month, -6, Now())
I've searched in the internet and this syntax is supposed to work, but I get this error message
Column "MONTH" cannot be found or is not specified for query. (13865)
As if it didn't have the parameters I think it has, which are "interval, number, date", but something else.
Any idea about this?
This is what you need:
DateAdd("m", -6, Now)
Or even DateAdd("m", -6, Date)
, if you want to get rid of the hours, coming from Now
.
Thus, you have to declare that you want the "Months" to be substracted.
WHERE Note_0.Relate_key = Work_history_0.WO_Key AND Work_history_0.Order_date > ADD_MONTHS(curdate(), -6)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.