I need to get all the data based on the user selection of the months. So, I will provide a dropdown will all list of the months. When user pick the month, for example January, then I will show all the invoice on January. How to get the month of the year in the where clause in T-SQL?
TIA
...WHERE MONTH(yourDateColumn) = @.selectedvaluefromDL|||Thank you Dinakar,
But I want to take the specific month in particular year. So, if I say month(o.InvoiceDT) = 6; it will take only June 2006.
TIA
|||Can you provide an example of what the user input will be and some sample data in your table and the expected result from the sql query?|||The dropdown would be January - December which has value 1-12. Then, my table is Order table which has InvoiceDT = mm/dd/yyyy (ex. 11/30/2006).
Then, I want to write in my query such as: WHERE InvoiceDT = @.Month ??
Since, I only get the input from the user as Month, how can I Get the month of the current year.
Hope this helps
|||hi ,
ideally you should also provide list of years but you can try following
select * from table where month(datefield) = dropdown.selectedvalue and year(datefield) = year(getdate())
regards,
satish.
|||Thank you satish|||no problems,
cheers
satish
No comments:
Post a Comment