title: Python - why do I get this error converting date format?
body: <p>I'm getting an error when I try to convert the date format into something mongodb understands a little better:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\tdun0002\OneDrive - Synchronoss Technologies\Desktop\important_folders\Jokefire\git\jf_cloud_scripts\aws_scripts\python\aws_tools\ec2_mongo.py&quot;, line 516, in &lt;module&gt;
      main()
    File &quot;C:\Users\tdun0002\OneDrive - Synchronoss Technologies\Desktop\important_folders\Jokefire\git\jf_cloud_scripts\aws_scripts\python\aws_tools\ec2_mongo.py&quot;, line 505, in main
      print_reports()
    File &quot;C:\Users\tdun0002\OneDrive - Synchronoss Technologies\Desktop\important_folders\Jokefire\git\jf_cloud_scripts\aws_scripts\python\aws_tools\ec2_mongo.py&quot;, line 363, in print_reports
      inputDate = inputDate.strftime(format)
  AttributeError: 'str' object has no attribute 'strftime'
  </code></pre>
  <p>This is my code:</p>
  <pre><code>def print_reports():
      inputDate = input(&quot;Enter the date in format 'dd/mm/yyyy': &quot;)
      day,month,year = inputDate.split('/')
      isValidDate = True
      try:
          datetime(int(year),int(month),int(day))
      except ValueError :
          isValidDate = False
  
      format= &quot;%m%d%Y&quot;
      inputDate = inputDate.strftime(format)
  </code></pre>
  <p>What am I doing wrong?</p>