Date format problems

Copper Contributor

I am working on a data set output from a blood sugar test meter (Bayer Contour Next USB)

1020 rows, 19 columns. Imported as CSV. 

I want to sort the data by the date column but from row 400 onward it will not sort by date order. I have tried altering the date format of the column, but only rows 1 to 399 will do change format, the rest stay as they were and the sort function does not recognise the rows as dates and will not sort them.

I have tried saving as .xlsx. Same problems.

Any ideas anyone?

7 Replies

@Stewart_H 

That's since some "dates" are kept as text, some are converted wrongly.

image.png

Importing csv file do not rely on automatic conversion. If that's legacy wizard, on third step apply Date to this column with MDY format. 

@Stewart_H some date in date column is import as text for sorting all the date it is essential that all are in date format i used text to column in data tab to convert all your date in date format i have attached a solution file check it, 

@Khizar_Hayat 

I'm not sure that is correct result. Let take these two records in initial file

image.png

Most probably in #54 in source csv file it was 11/08/2019. Since both 11 and 08 are less than 12, Excel was interpreted $54 as date in local format and converted to Aug 11. Text to Columns on result keeps converted date as it is, thus we have

image.png

Most probably in #54 it shall be Nov 08, or 2019-11-08 in ISO format. Same for some other records.

 

Thus I'd suggest to convert properly source csv file, not to transform intermediate files.

@Sergei Baklan 

Yes, that is the issue. Some of the text will not reformat to date.

The CSV file is created by the software on the blood test meter which is not accesible by me. Can I control how excel converts it when I open the CSV file?

@Khizar_Hayyat has managed to convert all cell to date format but day and month have been mixed up.

@Khizar_Hayyat How did you convert all to date format?  Simple explaination for excel novice please.

 

@Stewart_H 

It's better not to click on csv file to open it, but import csv into the blank Excel file. How to do - it depends on which version of Excel you are.

 

Assuming one of the latest for Windows Desktop. Here is also two options. You may enable legacy From text connector in options

image.png

and use it as

image.png

for older Excel that's the only option by default.

After you select the file it'll be 3-steps wizard, practically same as for Data->Text to Columns which @Khizar_Hayat  used. Here select separation by delimiter, your delimiter, and on 3rd step of the wizard check Date for the column with dates and select MDY format.

 

Another way is default for the latest Excel option uses Power Query

image.png

which is much more powerful and most probably will give you correct result without additional manipulations, but it requires to invest bit more time to start working with it.

@Sergei Baklan your solution is too powerful but it takes a lot of time but i am sure this is the right way to done it

 

@Stewart_H 

step 2step 2

 

step 3step 3

 

Screenshot_13.jpg

 

note: be carefullynote: be carefully

 

hope that you will find it good