Forum Discussion
noodles1030
Apr 09, 2024Copper Contributor
The given value of type String from the data source cannot be converted to type nvarchar of the spec
Hi, I am creating a date variable and attempting to write that variable to a SQL table. In my PS script, I do this: $DateTime = $((Get-Date).ToString('yyyy-MM-dd-hh_mm_ss')) I have tried set...
olafhelper
Apr 09, 2024Bronze Contributor
$DateTime = $((Get-Date).ToString('yyyy-MM-dd-hh_mm_ss'))
noodles1030 , your format string is wrong, no culture setting supports underscores in the time portion, see Standard date and time format strings - .NET | Microsoft Learn
noodles1030
Apr 11, 2024Copper Contributor
olafhelper - I have changed that previously and it still will not work. If it is just a string and not datetime, why would that matter?
It is interesting - I can do the same thing with the same PowerShell script and write to a different table and it works. The column in the 2nd table is also nvarchar... any idea on that?
Thanks!