DateValue


Definition: Returns a Variantof subtype Date.

 

How can you make sure Windows PowerShell treats a value as a date and not as, say, a string? One way is to explicitly “cast” that value as a date-time value. For example, this command assigns the string 12/1/2006 to the variable $a, at the same time making $ a adate-time value:

 

$a = [ datetime] "12/1/2006"

 

When you run this command and then use the GetType () method to retrieve the data type for $a you should get the following:

 

IsPublic IsSerialName
-------- -------- ----
True     True     DateTime