0

I am trying to convert TimeStamp to Date format for easier comparisons to fetch records from my MySqlX db but when I try to query it like this

DbDoc docData = new DbDoc(new { _startDate = startDate.Value.ToString("yyyy-MM-dd"), _endDate = endDate.Value.ToString("yyyy-MM-dd") });
collection.Find("DATE_FORMAT(TimeStamp, '%Y-%m-%d') >= :_startDate AND DATE_FORMAT(TimeStamp, '%Y-%m-%d') <= :_endDate").Bind(docData).Execute()

I get an error which says "Sequence contained null element\r\nParameter name: values

How do i solve this Unable to understand where I am going wrong

I am expecting the query to fetch all records on the db comparing only dates and leaving out the time part

3
  • Is this a c# or a MySQL error? Commented Jul 1, 2024 at 9:07
  • It is a mysql error Commented Jul 1, 2024 at 14:08
  • Forgive me but as far as I can see, it's unclear whether the error message pertaining to either. Could you use the same query to run directly in your MySQL and see if there's an error there? You should be able to get the exact MySQL error message (if any) then add into your question. You can use this as example dbfiddle.uk/XdQ_w15d Commented Jul 2, 2024 at 2:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.