PSSQLite icon indicating copy to clipboard operation
PSSQLite copied to clipboard

Invoke-SqliteQuery : Exception calling "Fill" with "1" argument(s): "String was not recognized as a valid DateTime."

Open boochkn opened this issue 6 years ago • 2 comments

The SQLite db I am attempting to get date from has columns that are in a Date/Time format like this 2019-07-02 04:59:18.578 +00:00 . It seems my queries all fail to pull back the data with the error in the subject line. Is there an override or way to convert it to string?

I have tried using all the -As param options, all give same error.

Example of query that fails "Select * From table_name;"

I am iterating through tables to find specific named columns and then getting that data so I can't easily just grab all columns besides the ones with the date/time.

boochkn avatar Nov 15 '19 04:11 boochkn

I had this problem as well. I checked the table pragma and I had declared a column as the wrong type.

sean-sauve avatar Jun 03 '20 03:06 sean-sauve

@boochkn I was unable to replicate the issue though I think sean-sauve may be right on checking the type of the column. According to SQlite doc, it could be TEXT, REAL or INT. If you can provide further schema info or a replication case. I'll take a look.

I ran this to create a table with a iso formatted time stamp and didn't experience the error you did.

Invoke-SqliteQuery @d -Query "create table n27 (date TEXT)"
$date = Get-Date -Format "yyyy-MM-dd HH:MM:ss.mmm"
Invoke-SqliteQuery @d -Query "insert into n27 (date) values ('$date')"
Invoke-SqliteQuery @d -Query "insert into n27 (date) values (datetime('now'))"
Invoke-SqliteQuery @d -Query "select * from n27"

@RamblingCookieMonster This issue may already be resolved as per sean-sauve's comment.

bgwdotdev avatar Jul 24 '20 07:07 bgwdotdev