I need to check the income for a particular department for a certain period of time.
My inputs are the two dates between which the income has to be calculated,and the department name,the department name is the primary key for my table
I need to show the transactions for the department for that period of time and also calculate the total income for the department in that time.
I have datetimepicker1 and datetimepicker2 giving the date inputs and combobox1 giving the department name.
Please help me with the sql query.
Thank You :)

Recommended Answers

All 2 Replies

SQL is pretty close to spoken language...just write out what you are asking for:
SELECT transactions
FROM yourtables
WHERE transaction date between date 1 and date 2.

All you need then is to use the right table and column names and you're pretty much done...for the between you can either use less than and greater than comparisons or check out BETWEEN operator.

I'm not going to give you the compelte syntax because this is a fairly simple query and you should at least have a go yourself. You wont learn if you dont try :)

SQL is pretty close to spoken language...just write out what you are asking for:
SELECT transactions
FROM yourtables
WHERE transaction date between date 1 and date 2.

All you need then is to use the right table and column names and you're pretty much done...for the between you can either use less than and greater than comparisons or check out BETWEEN operator.

I'm not going to give you the compelte syntax because this is a fairly simple query and you should at least have a go yourself. You wont learn if you dont try :)

Thank You. :)
Worked very nicely. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.