ultraman Posted July 19, 2004 Posted July 19, 2004 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 ? Quote 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
Administrators PlausiblyDamp Posted July 29, 2004 Administrators Posted July 29, 2004 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()); Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.