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)

```
there are multiple ways to convert string to datetime in python. it is based on the requirement of the user which function to use.

one possible solution could be as given below.

```
import timestring
start_period = "2019-04-22 00:00"
print(timestring.Date(start_period))

```