-2

I am using python to pull some records from sybase db and writing it in csv file but am receiving the date in the format JUL 22 12:00AM, while I need it to be in dd/mm/yyyy HH24:MI:SS format. Could you please suggest any workaround?

we cannot change the query which is pulling the records,so formatting the query will not work.

the data in table is in dd/mm/yyyy HH24:MI:SS format .

James Z
  • 12,209
  • 10
  • 24
  • 44
Anu
  • 1

1 Answers1

0

You can take a look at date.strptime() function:

from datetime import datetime

datetime.strptime("JUL 22 12:00AM", "%b %d %I:%M%p")

I also recommend you to take a look in other Stack Overflow questions which may help you:

João Eduardo
  • 452
  • 5
  • 10
  • thank you for the solution, but I have the result in a csv file , the file contains other datatype columns also .How do you suggest to change the date format – Anu Apr 29 '19 at 14:29
  • Sorry but didn't understand what do you mean by having other datatype columns in the csv file. Could you explain it in more details in the question? – João Eduardo Apr 29 '19 at 14:39