Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
boochkn opened this issue Nov 15, 2019 · 2 comments

Comments

@boochkn
Copy link

boochkn commented Nov 15, 2019

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.

@sean-sauve
Copy link

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

@bgwdotdev
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants