Here is my code piece:
#region Validate and prepare parameters
if (month > 12)
{
throw new ArgumentException("Value of 'month' could not be greater than 12.");
}
int yearEnd = year;
int monthEnd = 0;
if (month != 12)
{
monthEnd = month + 1;
}
else
{
monthEnd = 1;
yearEnd = year + 1;
}
#endregion
MyModelDataContext context = new MyModelDataContext();
string sql =
@"select SUM(ORDERQTY * MULTIPLIER) AS VOL_USD
from Executions with (nolock)
where TRANSACTTIME >= '{0}-{1}-01 00:00:00'
and TRANSACTTIME < '{2}-{3}-01 00:00:00'
and MTCONTEXT in (5,6)
and ORDERQTY > 0
AND SOURCE = 'INTMT'
and LEFT(SYMBOL, 3) = 'USD'";
decimal usd___Sum = context.ExecuteQuery<decimal>(sql, year, month, yearEnd, monthEnd).First();
I'm getting the exception:
Conversion failed when converting date and/or time from character string.
when I call ExecuteQuery method. The value of year is 2013 and the value of month is 9. What am I doing wrong?
Thanks in advance.