Dates package: "m" delimiter via \m produces escape sequence error

I’m trying to import a CSV file that has a date column with a string entry say “2001m1” for January 2001, so that the delimiter is the letter “m”. Using the Dates package (and DataFrames), I’m trying to translate this column to a common date format. Documentation in Dates · The Julia Language states that
The date “1995y01m” would have the format “y\ym\m”.

I import the CSV data as a dataframe df, with the date column called say :datem. However, when I try to use the suggested format, the operation Date.(df.datem, “y\mm”) produces “ERROR: syntax: invalid escape sequence”. The format “y\m\\m” (using a double backslash \\ as the escape sequence for \) also doesn’t work. Any advice on how to to use the letter “m” as a delimiter in Dates would be greatly appreciated.

julia> Date("2001m1", "y\\mm")
2001-01-01

julia> Date("2001m1", dateformat"y\mm")
2001-01-01


1 Like