Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Compare dates

$
0
0
Hello,

I am selecting a date from the database, then if it is earlier than today I want to run some code. I can't seem to get the syntax correct for this. Here is what I have:

// Get info from DB
string sql = DB.PrepareSQL("select LastSynch from Promos where ID = :master.ID");
XVar rs = tDAL.CustomQuery(sql);
XVar data = CommonFunctions.db_fetch_array(rs);

// Now compare date to today
if (data["LastSynch"] < DateTime.Now) {
Do some stuff
}


When I do a build I get this error:

Operator '<' cannot be applied to operands of type 'runnerDotNet.XVar' and 'System.DateTime'


I have tried several ToString() methods, but I get an error that strings can't be evaluated for < , which makes sense. I need these to be dates. I get that. How do I get the value that is returned from the DB query to be in a data format so that I can compare it to the system date?

Thanks,
Tim

Viewing all articles
Browse latest Browse all 2586

Trending Articles