I'm try to us the following code
string timespent1 = "SELECT DATEDIFF(minute ,departureTime,entryTime) AS timespent FROM mambo where plateno = '" + TextBox1.Text + "'";
SqlCommand comman = new SqlCommand(timespent1, conn);
comman.Parameters.AddWithValue("@timespent", ToString());
comman.ExecuteNonQuery();
where departureTime is the departure time and entryTime is the entry time both in data type of datetime
unfortunately is returnining a null value in the database.

Manas MohapatraRank #182 · 13.2K reputationPosted Jul 24, 2016, 9:20 AM EDT
simon macharia6 reputationPosted Jul 24, 2016, 8:30 PM EDT
ali tuncerRank #1,499 · 1.1K reputationPosted Jul 24, 2016, 8:55 PM EDT
DATEDIFF will return null if one or both columns(departureTime,entryTime) have null values..
Suthish NairRank #92 · 22.8K reputationPosted Jul 24, 2016, 10:42 PM EDT