[RESOLVED] Using DatePart in SQL
I have a table called Requests and I'd like to return values grouped by the month value of a field named 'Sentdate' which is formatted in the database as a General Date. I tried the following but gat a "no value given for one or more parameters" error. What am I doing wrong?
rs.Open "SELECT count(*), DatePart(month, SentDate) FROM Requests group by SentDate", cn, adOpenDynamic, adLockOptimistic
Re: Using DatePart in SQL
Can you try it like this?
Code:
"SELECT count(*), DatePart(month, SentDate) FROM Requests group by DatePart(month, SentDate)"
EDIT:
Upon testing it should be like this (works in Access)
Code:
"SELECT count(*), DatePart('m', SentDate) FROM Requests group by DatePart('m', SentDate)"
Re: Using DatePart in SQL
I worked it out a different way.