Click here to Skip to main content
15,174,232 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a DateTime list that stored in the SQLite database and I try to read the date value that fall in specific date range from the file.

Currently, I am able to read the date value that fall in the specific range.

Original DateTime List:
11-08-2021 15:16:44
11-08-2021 17:09:22
11-09-2021 17:20:39
...
11-11-2021 09:31:54
11-11-2021 10:35:37
11-11-2021 10:45:11
11-11-2021 11:54:28


Datetime List that fall in the specific date range:
11-11-2021 09:31:54
11-11-2021 10:35:37
11-11-2021 10:45:11
11-11-2021 11:54:28


The next thing that I want is I want to check the Datetime difference among the date value that I filtered out before.

For example, there is more than 1 hour difference between 09:31:54 and 10:35:37. How I detect the time difference between these two dates? While between 10:35:37 and 10:45:11, there is not more than 1 hour, so just ignore it. The way I want to check in this way because when the DateTime difference is more than 1 hour between the date, I need to run something in the DateTime behind.

Is it possible to check in this way? I stuck at here and have no idea how can I check the time difference among all the date value. Any suggestion?

What I have tried:

Here is the code that I read the date value that fall in specific date range.
using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + path)
{
    connection.Open();
    string queryDate = DateTime.Now.AddHours(-6).ToString("MM/dd/yyyy HH:mm:00Z");
    string consulta = $"SELECT * FROM LastRun WHERE LastUpdatedTime > '{queryDate.ToString()}' ";

    using (SQLiteCommand commandReader = new SQLiteCommand(consulta, connection))
    {
        SQLiteDataReader reader = commandReader.ExecuteReader();

        while (reader.Read())
        {
            DateTime suaData = Convert.ToDateTime(reader[0]);
            Console.WriteLine("datetime: " + suaData);

        }
    }
}
Posted
Updated 10-Nov-21 21:01pm

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900