HOw? Query to return last day .

sql server India
  • 12 years ago

     Hi, I have a table named "dateTble" with a column named "engDate". 

    The attributes of the "engDate" are like..

    18/12/2005 

    19/12/2005

    20/12/2005

    21/12/2005

    22/12/2005

    23/12/2005

    24/12/2005 

    .

    .

    .

    and so on.

    (The format of the date is DD/MM/YYYY) .

    Now how do I find the last day in the particular date. Like I need to write a query that returns the last day in 7th month and 2006 year. (The month and the year is selected from the combo box. )

    Please help !!

  • 12 years ago

    Hi

    Write the stored procedure with the parameters @Month and @Year. Pass the values of Month and Year which are selected from the combo box.

     the Query is as follows

     

    SELECT MAX(DAY(engDate)) FROM DATETABLE WHERE MONTH(engDate)=@Month

    AND YEAR(engDate)=@Year

    If you pass the values @Month=12 and @Year=2005 to the above query. You will get the last day as you wanted.

    Let me know if you need any more information..

     

    All the best..

    Gayatri Kumar

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”