I tried using datetime_format = 'dd/mm/yyyy hh:mm:ss AM/PM' but this didn't change it. How else can I get the date to format like this?
Asked
Active
Viewed 93 times
0
-
2Please post your code as text. – Rahul K P Oct 27 '22 at 06:11
-
I need to get date and time in excel sheet as dd/mm/yyyy hh:mm:ss AM/PM and i tried format7 = workbook.add_format({'num_format': 'dd/mm/yy hh:mm:ss AM/PM', 'align': 'left'}) worksheet.write_datetime('C3:D3', conflict_report.affected_at.date(),format7) But error message popuped – Arundev Ummalath Oct 27 '22 at 06:15
-
1What was the error? Please add it to the question. – jmcnamara Oct 27 '22 at 07:13
-
No error. I can't get the date format as i wanted to . That's the problem – Arundev Ummalath Oct 27 '22 at 07:36
-
2Please provide enough code so others can better understand or reproduce the problem. – Community Oct 27 '22 at 09:10
-
Does the `.date()` method return a Datetime instance or a string in date format? – jmcnamara Oct 27 '22 at 10:49
-
@jmcnamara it returns date as dd-mm-yy and 12:00:00 AM , the time is not changing . it is fixed as 12:00 am and date format also not changing the format to dd/mm/yyyy. – Arundev Ummalath Oct 28 '22 at 04:57
-
If the format isn't applying then the most common reason is that the data it is being applied to is a string and not a number/date. That is why I asked if that function returns a string or date. – jmcnamara Oct 28 '22 at 08:51