Hello everyone
I'm writing something for fun using both C# and MySQL.
To make things short I want to check if a certain user registered more than 24 hours ago.
I have made a collumn in my table "users" called "timereg", indicating the time they registered. The values of the collumn are as follows:
Now I want to create a function to compare the timestamp in the database and the current time (using DateTime)Code:`timereg` timestamp NOT NULL DEFAULT 'CURRENT_TIMESTAMP',
here is my function
Now, the problem is that I don't know how to compare the two. Could anyone help me with what function I should use to compare the two? In other words, instead of "data.GetTimeSpan", is there another function that I can use?Code:public static void check(string username) { Server.Database.RunQuery("SELECT `timereg` FROM users WHERE name = '" + username + "'"); MySqlDataReader data = Server.Database.Reader; if (data.GetDateTime("timereg") > DateTime.Now.TimeOfDay) { //whatever here } else if (data.GetTimeSpan("timereg") < DateTime.Now.TimeOfDay) { //whatever here } data.Close(); }
Thanks.




Reply With Quote