Hi guys,
I m trying to use custom format in dateTimePicker like this
$dateTimePicker.Format = DateTimePickerFormat.Custom
$dateTimePicker.CustomFormat = "dd MM yyyy"
But i always get this error :
DateTimePickerFormat.Custom : The term 'DateTimePickerFormat.Custom' is not recognized as the name of a cmdlet
Does anyone can help please.
Thx in advance.
Seb
DateTimePicker Custom Format doesn't work
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: DateTimePicker Custom Format doesn't work
Update your format line to look like the following:
Code: Select all
$dateTimePicker.Format = [Windows.Forms.DateTimePickerFormat]::Custom
Brittney Ryn
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: DateTimePicker Custom Format doesn't work
Yesss pretty cool. That works.
But after that, when i use the variable $dateTimePicker the result is : System.Windows.Forms.DateTimePicker, Value: 11/13/2020 2:16 PM
I need to have just 11/13/2020
How can i do that please ?
But after that, when i use the variable $dateTimePicker the result is : System.Windows.Forms.DateTimePicker, Value: 11/13/2020 2:16 PM
I need to have just 11/13/2020
How can i do that please ?
Re: DateTimePicker Custom Format doesn't work
To use with Set-ADAccountExpiration -Identity $identity -DateTime $dateTimePicker
Re: DateTimePicker Custom Format doesn't work
When i use it like this it give me this error :
Set-ADAccountExpiration : Cannot bind parameter 'DateTime'. Cannot convert the "System.Windows.Forms.DateTimePicker,
Value: 11/20/2020 2:22:58 PM" value of type "System.Windows.Forms.DateTimePicker" to type
"System.Nullable`1[System.DateTime]"
Set-ADAccountExpiration : Cannot bind parameter 'DateTime'. Cannot convert the "System.Windows.Forms.DateTimePicker,
Value: 11/20/2020 2:22:58 PM" value of type "System.Windows.Forms.DateTimePicker" to type
"System.Nullable`1[System.DateTime]"
Re: DateTimePicker Custom Format doesn't work
That is because you are passing the DateTimePicker control, not a DateTime object. To get the DateTime object from your object, you would pass something like this:
Code: Select all
$dateTimePicker.Value
Brittney Ryn
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.