Shaitan00 Posted February 22, 2005 Posted February 22, 2005 Given a Dataset [ds] that contains a DateTime Stamp isolated from each row as a string [strDeadLine]. I need to compare each strDeadline [of each row] to NOW (the present datetime). So, I need a way to compare the strDeadline string I got from the Dataset and the current datetime. I have looked into a few methods but none seem to give me the correct results. I have tried converting the strDeadline into a DateTime object using Convert.DateTime but when doing that I loose the Time (only the DATE remains). Also I am unable to get DateTime.Now() to work correctly. So the other choice was compare the strings, this obvisouly doesn't work (cannot compare strings...). Pull the value from the dataset as a DateTime (how would that help?) So I am stuck, any suggestions? Currently the format of my strDeadline = "2/10/2005 11:49:45 PM" And that is what I need to compare with NOW so if time passed then ..... etc. Quote
Leaders snarfblam Posted February 22, 2005 Leaders Posted February 22, 2005 I just tried this with the string you provided ("2/10/2005 11:49:45 PM") and others with the same format. I converted it to a DateTime using both System.Convert.ToDateTime() and DateTime.Parse(), and both ways it properly converted to a DateTime, retained both the date and time data, and compared properly with DateTime.Now(). Perhaps you should post some code. I am not experiencing any of your problems. I don't know if this may help, but try looking at the overloads for DateTime.Parse(). Quote [sIGPIC]e[/sIGPIC]
*Experts* DiverDan Posted February 22, 2005 *Experts* Posted February 22, 2005 You can also convert the dates to a Jullian type date with .ToOADate which produces a decimal number like 123546.456456, the whole numbers being the days and the decimal part the time. Then just compare them as normal Doubles or Decimals. btw: would that be Hell in Grand Cayman? Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.