Reputation: 51
Trying to insert data into SQL with PS. This is my code:
$date = Get-Date -Format 'dd/MM/yyyy HH:mm:ss'
***Oracle Connection***
$Command.CommandText = "insert into Datetest VALUES ('$date')"
$command.ExecuteNonQuery()
$OracleConnection.Close()
The problem is, that the first column of the SQL Table requires data from type date and the following structure: 'dd/MM/yyyy HH:mm:ss' but everytime I try to insert such data it gives me this error:
"ORA-01830: Datumsformatstruktur endet vor Umwandlung der gesamten Eingabezeichenfolge "
En:
"ORA-01830: date format picture ends before converting entire input string"
When I just insert 'dd/mm/yyyy' it works, but it nulls the time...
Any ideas how to insert date & time into SQL?
Upvotes: 0
Views: 456
Reputation: 19204
Going by these examples
https://www.tutorialspoint.com/how-to-insert-and-retrieve-dates-in-oracle
Try this
$date = Get-Date -Format 'yyyy-MM-dd'
$Command.CommandText = "insert into Datetest VALUES (DATE '$date')"
$command.ExecuteNonQuery()
$OracleConnection.Close()
Upvotes: 0