CDate


Definition: Returns an expression that has been converted to a Variantof subtype Date.

 

Need to make sure that a value is treated as a date? Then do this. First, assign the value to a variable; here we’re assigning the string 11/1/2006 to the variable $a:

 

$a = "11/1/2006"

 

In fact, if we now call the GetType ( )method we’ll see that $a is a string variable:

 

IsPublic IsSerialName
-------- -------- ----
True     True     String

 

To convert $a to a date-time value we can use this command:

 

$a = [ datetime] $a

 

When you run this command and check the data type for $ a youshould get the following:

 

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