Question

  Asked: Mar 13 2008   9:26 AM GMT
  Asked by: Blue


how to compare 2 dates == x day and delete the file


C, MySQL

hi, do any one know how to compare the 2 dates.comparing today's and the file created date using mysql and c# here is my program but i am stuck


string ConnectionString = "server=localhost;user id=name;password;persist security info=True;database=name of database;";
using (MySqlConnection conn = new MySqlConnection(ConnectionString))
{
MySqlCommand cmd = new MySqlCommand();
conn.Open();
if (conn.State == ConnectionState.Open)
{


cmd.Connection = conn;
cmd.CommandText = "select history ,lastclrhistorydate from table;";
cmd.CommandType = CommandType.Text;
MySqlDataReader reader;
reader = cmd.ExecuteReader();
if ((reader != null))
{
DataTable dt = new DataTable();
dt.Load(reader);

if (dt.Rows.Count == 1)
{
int history = int.Parse(dt.Columns[0].ToString());

string lastclrhistory =dt.Columns[1].ToString();
DateTime currentdate = DateTime.Now;


if ((currentdate - lastclrhistory) == history)
{
//(File.delete(file)
}

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


Start this Answer and Earn your Knowledge Points!

By clicking "Create Answer", you can write the answer to this question that can be improved upon by your peers using the Answer Wiki.

Browse more Questions and Answers on Development and Database.

Looking for relevant Development Whitepapers? Visit the SearchSQLServer.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register