Thread: Time span Help
View Single Post
Old 02-23-2007   #2 (permalink)
mikes.net


 
 

Re: Time span Help

Because in the second example you did not and could not issue the two
date commands intantaneously. Notice that the number of days is
almost 631:

TotalDays : 630.996613136574.

Perhaps the following will help you to see this better:

PS > $tomorrow =(get-date).adddays(1)
PS > $today = get-date
PS > $tomorrow - $today

Days : 0
Hours : 23
Minutes : 59
Seconds : 54
Milliseconds : 500
Ticks : 863945000000
TotalDays : 0.999936342592593
TotalHours : 23.9984722222222
TotalMinutes : 1439.90833333333
TotalSeconds : 86394.5
TotalMilliseconds : 86394500

Did I misunderstand the question?

Mike



On Feb 23, 5:05 am, "Techstarts" <preetamz...@gmail.com> wrote:
> I'm trying to find the amount of time between spend between june 02 till date. I'm getting different results if I use timespan and when I use Subtract method.
>
> Comment would clarify concept behind it.
>
> PS E:\cmdlets> New-TimeSpan (get-date -day 02 -month 06 -year 2005)
>
> Days : 631
> Hours : 0
> Minutes : 0
> Seconds : 0
> Milliseconds : 0
> Ticks : 545184000000000
> TotalDays : 631
> TotalHours : 15144
> TotalMinutes : 908640
> TotalSeconds : 54518400
> TotalMilliseconds : 54518400000
> --------------------------------------------------------------------------------
> $M=get-date -Year 2005 -Month 06 -Day 02
> $T=get-date
> $T.subtract($M)
>
> PS E:\cmdlets> $T.Subtract($M)
>
> Days : 630
> Hours : 23
> Minutes : 55
> Seconds : 7
> Milliseconds : 375
> Ticks : 545181073750000
> TotalDays : 630.996613136574
> TotalHours : 15143.9187152778
> TotalMinutes : 908635.122916667
> TotalSeconds : 54518107.375
> TotalMilliseconds : 54518107375



My System SpecsSystem Spec