Dear statalist,

I need to convert numbers to dates (format: 1/1/2019). The numbers are a string variable, and are in the following format (mdy):

datenumber
12232019
12202019
12192019
12192019
12192019
12182019
12182019
12162019
10122019
05122019
05122019
03122019
11252019
11182019
11182019
11152019
06112019
...

Notice that the months and days always exist of two digits (so sometimes it starts with a zero).
I used the code:

gen date= date(datenumber, "MDY")

But only missing values were generated. I would be very thankful if you can provide me with guidance or code to solve this issue. Eventually, I want the dates to be in the format: m/d/y: so 1/1/2019. Thank you very much in advance.

Floris Bedkom