how to compare the time and date using mysql and c#


Problem :

I have a table logout with columns

logout_id
logout_datetime  values format like this(2011-09-08 11:09:09)

and i want to compare the logout_datetime with today date and time also....

for that i have done like this....

string dtStartString = DateTime.Today.ToString("yyyy-MM-dd");
string timeonly = DateTime.Now.ToShortTimeString();

string sql = @"select logout_id"; 
sql+= string.Format("where logout_datetime = '{0}'",dtStartString );

but it will compares only date in logoutdatetime ,its wrong i want to compare the time also

how can i do this..

would any one pls help on this...



Solution :

Of course your code is only comparing the date because you are passing only dtStartString which does not have a time part.

try to pass this:

string dtStartString = DateTime.Now.ToString("yyyy-MM-dd  HH:mm:ss");

Mysql Tutorials

Mysql Howto..

How to solve SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry?

mysql, how to join this key id?

How to convert any image to bitmap image and store in MySQL database using PHP?

How to insert into a mysql table only if not already existing?

How to create and insert a JSON object using MySQL queries?

How can I retrieve and display data from mysql database using php PDO? [closed]

Visual C++ how to find name of a column in MySql

How to reset AUTO_INCREMENT in MySQL?

How to create revision date php script?

How does MySQL server retrieve and send data to clients? [closed]

How to 'append' a mysql column onto another

How to get the first process ID in MYSQL of the current user?

How to order by maximum of two column which can be null in MySQL?

How to fill the values in a textbox using Ajax or Jquery?

How to get mime type of blob data avialable?

How do I design my database with lots of columns?

How to merge null values with not null values of several columns in mysql table?

How do I store and iterate over a result set in a MySQL Stored Proc?

How to tell the difference between a MySQL GA release and milestone build

How to query huge MySQL databases?

How to parse csv file into mysql DB with PHP with conditions

MySQL - How to simplify this query?

How to use MySQL's REPLACE Syntax in Rails

How to query sum in doctrince 2 with dql?

MySQL sorting: how to make Cyrillic characters go before Latin characters?

How to create a MySQL user without password - needed for remote login - to be used in bash insert script?

How to display data from mysql using angular.js PHP?

How can I make an android app for a website I do not own?

PHP - how can i make from array to comma separate for mysql

How to keep checking a MySQL database?