Hello Everyone
I am working on a file copy app. I have everything working correctly, but I have a small snag. I cannot have the end user always providing the current date. The files that I want to copy are created daily. I want to write the code that will use the current date, and use the time variables that I supply to compare with the file creation time.
So my question is: How can I compare the file time only with a variable?
Thank you in advance
Andrew SQLDBA
Compare File Time Only, no Date
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Manikavelu VelayuthamRank #413 · 6K reputationPosted Aug 24, 2010, 9:55 PM EDT
DateTime t1 = DateTime.Now;
DateTime t2 = Convert.ToDateTime("11:00:00 AM");
int i = DateTime.Compare(t1,t2);
Manikavelu VelayuthamRank #413 · 6K reputationPosted Aug 24, 2010, 9:57 PM EDT
DateTime systemDate = DateTime.Now;
DateTime compareDate = DateTime.Today.AddHours(11D);
// less than
if (compareDate < systemDate)
Console.WriteLine("Less Than");
// equal to
if (compareDate == systemDate)
Console.WriteLine("Equal To");
// greater than
if (compareDate > systemDate)
Console.WriteLine("Greater Than");