Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

q; find day passed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JIM.H. - 17 Jul 2006 21:53 GMT
Dim ts As TimeSpan = crun.Subtract(lrun)

I am using this to find the elapsed time, is there any way I can do this
comparison without time part, such as if lrun=07/16/2006 and crun=07/17/2006
I need to return 1 since there has been 1 day passed.
Jon Skeet [C# MVP] - 17 Jul 2006 21:56 GMT
> Dim ts As TimeSpan = crun.Subtract(lrun)
>
> I am using this to find the elapsed time, is there any way I can do this
> comparison without time part, such as if lrun=07/16/2006 and crun=07/17/2006
> I need to return 1 since there has been 1 day passed.

You can use the DateTime.Date property to return the original DateTime
but with the time portion set to midnight.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

JIM.H. - 17 Jul 2006 22:11 GMT
if I have lrun.Date and crun.Date, how should I compare what is the
difference between these dates in terms of days? Can you give me example?

> > Dim ts As TimeSpan = crun.Subtract(lrun)
> >
[quoted text clipped - 4 lines]
> You can use the DateTime.Date property to return the original DateTime
> but with the time portion set to midnight.
Jon Skeet [C# MVP] - 17 Jul 2006 22:41 GMT
> if I have lrun.Date and crun.Date, how should I compare what is the
> difference between these dates in terms of days? Can you give me example?

Subtract one from the other as you're doing now, then use the Days
property of the resulting TimeSpan.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.