Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi ! I'm trying to get the difference between Now() and a date from my DB in minutes. I tried lots o stuff, but nothing works.

 

Here's my latest :

 

dtStart = DateTime.Parse(strOutDate);  //from the DB
dtEnd = DateTime.Parse(strDateTimeNow);  //Now()
TimeSpan ts = new TimeSpan(dtStart.Ticks - dtEnd.Ticks);
intTimeBetwCurrAndPrev = int.Parse(ts.TotalMinutes.ToString());

 

The problem is that when the date is Parsed in the dtStart, the format is wrong and it only takes the date, not the time...

 

Anybody have an idea ?

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

  • 2 weeks later...
  • Administrators
Posted

Have you tried just subtracting the dates

dtStart = DateTime.Parse(strOutDate);  //from the DB
dtEnd = DateTime.Parse(strDateTimeNow);  //Now()
TimeSpan ts = dtEnd - dtStart;
intTimeBetwCurrAndPrev = int.Parse(ts.TotalMinutes.ToString());

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

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...