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.

Re: q; find day passed by Jon

Jon
Mon Jul 17 15:56:27 CDT 2006

JIM.H. <JIMH@discussions.microsoft.com> wrote:
> 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.

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

Re: q; find day passed by JIMH

JIMH
Mon Jul 17 16:11:01 CDT 2006

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?

"Jon Skeet [C# MVP]" wrote:

> JIM.H. <JIMH@discussions.microsoft.com> wrote:
> > 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.
>
> --
> 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
>

Re: q; find day passed by Jon

Jon
Mon Jul 17 16:41:56 CDT 2006

JIM.H. <JIMH@discussions.microsoft.com> wrote:
> 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.

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