Skip to content
Advertisement

SQL Filter by dateTime

string query = "Select  *From myTable where myTime>datetime('now','localtime','" + (-1 * day).ToString() + " days') ORDER BY myTime DESC";

day is a integer variable. If I set the day value to 1, database is filtering for 24 hours.

But if I set the day value to 1, I only want to see the logs of the new day.

How can I do that? Thank you for your help.

Advertisement

Answer

string query = "Select  *From myTable where myTime>datetime('now','localtime','start of day', '" + (-1 * day).ToString() + " days') ORDER BY myTime DESC";
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement