1. For FORMAT$, look in SQL BOL for Convert. Something like Convert(Varchar(7), [Main Table].[Date]
Originally Posted by desireemm
2. For your parameter ([Enter the Month and Year]), you will likely have to create the query as a stored procedure with an input parameter (or two). Something like:
CREATE PROC spMyProc (@MonthYear varchar(7) )
MyDateString = @MonthYear
You would have to validate that @MonthYear was valid (like mm/yyyy). I would not necessarily do it this way. I would use one of the following options:
1. Declare the incoming parameter as a datetime and calculate the first and last day of the month. Then use two local variables and a BETWEEN statement. This should render the best performance for large amounts of data.
2. or Declare the incoming parameter as two smallint variables. Then you could use DatePart function twice to get month and year.
Have you hugged your backup today?