Export (0) Print
Expand All
Expand Minimize

Converting VBScript's DateValue Function


Windows PowerShell


Definition: Returns a Variant of subtype Date.

DateValue

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 a date-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 IsSerial Name
-------- -------- ----
True     True     DateTime


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft