I have a column where a date store in ddmmyy format (e.g. 151216). How can I convert it to yyyy-mm-dd format (e.g 2016-12-15) for calculating a date difference from the current date? I try using DATE\_FORMAT function but its not appropriate for this.
['https://Stackoverflow.com/questions/45003631', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2231075/']
If you want to get the date difference, you can use `to_days()` after converting the string to a date using `str_to_date()`:

```
select to_days(curdate()) - to_days(str_to_date(col, '%d%m%y'))

```

or `datediff()`:

```
select datediff(curdate(), str_to_date(col, '%d%m%y'))

```

or `timestampdiff()`:

```
select timestampdiff(day, str_to_date(col, '%d%m%y'), curdate())

```
```
SELECT STR_TO_DATE('151216', '%d%m%y') FROM `table`

```

use this '%d%m%y'