Hello,

i have a date variable in my dataset which is type "long" and formated in the following way:

date
28jun2017
04oct2017
09sep2014
11jan2016


I would like to change the formatting to make it look like this:

date
28-jun-2017
04-oct-2017
09-sep-2014
11-jan-2016

I tried this before:
tostring date, format("%09.0f") replace
gen date1=substr(date,1,2)+"-"+substr(date,3,9)
as a first step for the first "-"

but the "tostring" command converts the variable in numbers only, and the date information is somehow lost.
If i try tostring date, format("%09.0f") replace, the variable suddenly looks like this:
date
000020998
000021096
000019975
000020464

I hope someone can help me ! thank you !

PS: i tried to display the data with dataex but that also just gave me really weird looking values for the date variable.