v2kiran / PSLiteDB

PowerShell wrapper for LiteDB
MIT License
52 stars 6 forks source link

February 28th #12

Closed sdacalor closed 3 years ago

sdacalor commented 3 years ago

Hi Kiran,

Incredible. An object with datetime 28/02/2020 11:12:15, cannot be convert into BsonDate, line 3, position 28. May be this come from LiteDB.

Error Could not convert string to DateTime. Path BsonDate, line 3, position 28.

Any idea !

v2kiran commented 3 years ago

Hi Steeve without the context I am not sure at what point you are getting this error but this could be due to the date format.

for example consider this: US date format - M/d/yyyy whereas UK uses dd/MM/yyyy

if its a one off you can parse the format this way:

[datetime]::ParseExact('28/02/2020 11:12:15', 'dd/MM/yyyy hh:mm:ss', $null)
oolejniczak commented 3 years ago

I have similar issues. I managed to purge some date/time pattern within the string using regex to overcome the issue. Still have some issue while detection the type of type within a string. Can not understand the powershell code you use to identify the type de data.

v2kiran commented 3 years ago

@oolejniczak - the only type of data we try to infer from string is datetime because its the most common type within a string and even that can result in mismatch sometimes.

We cannot do that for other well known types or custom types because the only person(s) who would know the type of data they are dealing with are the people who use it so the onus is on the user to make sure that data with proper type is being sent to the database.

v2kiran commented 3 years ago

closing since there is no new comment.