I am using docdb. I would like to query the processTime with date only instead of datetime. My input pdate = 26-09-2017 which is dateonly. I am using cast function to convert datetime to date in sql query but I am getting syntax error. I am doing this in c#. Using LINQ for query
I have the following json in document db.
[{
"processTime": "2017-09-26T21:05:28.7954106+05:30",
"submittedBy": "671"
}
{
"processTime": "2017-09-26T21:05:28.7954106+05:30",
"submittedBy": "679"
}
{
"processTime": "2017-09-26T21:05:28.7954106+05:30",
"submittedBy": "679"
}
]
I am querying the db as follows
new SqlQuerySpec()
{
QueryText = "SELECT * FROM cols e WHERE e.submittedBy = @ci AND CAST( e.processTime AS int) = @date",
Parameters = new SqlParameterCollection()
{
new SqlParameter("@ci", cid.ToString()),
new SqlParameter("@date", pdate)
}
}, DefaultOptions);
I am getting syntax error near CAST function
{"Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":61,\"end\":65},\"code\":\"SC1001\",\"message\":\"Syntax error, incorrect syntax near 'CAST'.\"}]}\r\nActivityId: 5661ff3b-64cb-46d7-8c9e-0125145a8fb3"}