Question: Hello I am trying to convert a string which is `a = "2019-04-22 00:00"` to a datetime but it does not work, I tried this : 

```
a = datetime.datetime.strptime(a, '%Y-%m-%d %H:%M')

```

But I got 

> 
> time data 'start\_period' does not match format '%Y-%m-%d %H:%M'
> 
> 
> 

I precise `start_period` is get by this : `a = request.POST.get('start_period')`

Answer: 
Like this it should work:

```
import datetime
start_period = "2019-04-22 00:00"
a = datetime.datetime.strptime(start_period, '%Y-%m-%d %H:%M')

```

Result:

```
datetime.datetime(2019, 4, 22, 0, 0)

```
May I suggest using [dateutil](https://dateutil.readthedocs.io/en/stable/index.html) module, where you do not need to provide the format string

```
from dateutil import parser

print(parser.parse("2019-04-22 00:00"))
#2019-04-22 00:00:00

```