Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Leaders
Posted
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().
[sIGPIC]e[/sIGPIC]
  • *Experts*
Posted

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?

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...