0

I am trying to convert a column in a csv file that contains the following datetime format.

12 mar 2016 10:27:47 fm

But when I change type to DateTime I get this error:

Error: Could not parse the input provided to a DateTime value

I have tried converting using different locale as well with no success.

How can I convert it to a correct datetime format?

2 Answers 2

1

Our date/time parser for locales like Swedish where you'd use "fm" for "am" only allows 24-hour time. Sorry that you ran into this!

Alejandro's fix would look like:

DateTime.FromText(Text.Replace(Text.Replace("12 mar 2016 10:27:47 fm", " fm", " am"), " em", " pm"))
Sign up to request clarification or add additional context in comments.

1 Comment

It is a mix of the US locale date format "12 mar 2016 10:27:47 pm" but with the Swedish abbreviations for both am/pm and the month names. So I had to replace "maj" with "may" and "okt" with "oct" as well. Problem solved! Thanks for your help!
1

Should the fm on that line be am or pm?

You can work around it by replacing fm in the text with am or pm using Text.Replace and then using that text in DateTime.FromText.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.