SQL related problem

straight_edge

Member
Joined
Feb 21, 2007
Messages
13
Programming Experience
Beginner
Hi

I have a VB.Net program linked to an access database

I have a table called OrderProduct with a 'Cost' field and a 'OrderDate' field

I need to output to a textbox the sum of 'Cost' for todays month

This is the SQL command I have so far but it doesn't work

sql = "SELECT SUM(Cost) FROM OrderProduct where OrderDate = %/ & Month(Now).ToString() & /%"


If anyone can help I would be very grateful

Thanks
 
You want the sum of the Cost for the current month? YEah, that SQL isn't close....

try this:

SELECT SUM(Cost) FROM OrderProduct where MONTH(OrderDate) = MONTH(Now) AND YEAR(OrderDate) = YEAR(Now)

-tg
 
Back
Top