Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change format of datetime
#5
(Feb-04-2019, 08:52 PM)ichabod801 Wrote: What is not working?
>>> text = '2019-04-02'
>>> nums = [int(x) for x in text.split('-')]
>>> dt = datetime.date(*nums)
>>> dt.strptime('%b %d')
'Feb 04'

I've got this row above of code but can't use your script to get it right..
I tried this:
nums = [int(x) for x in due_date.split('-')]
>>> dt = datetime.date(*nums)
>>> dt.strptime('%b %d')
but with no luck.
Reply


Messages In This Thread
Change format of datetime - by Jonas85 - Feb-04-2019, 05:50 PM
RE: Change format of datetime - by ichabod801 - Feb-04-2019, 06:53 PM
RE: Change format of datetime - by Jonas85 - Feb-04-2019, 07:34 PM
RE: Change format of datetime - by ichabod801 - Feb-04-2019, 08:52 PM
RE: Change format of datetime - by Jonas85 - Feb-05-2019, 03:40 PM
RE: Change format of datetime - by ichabod801 - Feb-05-2019, 03:45 PM
RE: Change format of datetime - by Jonas85 - Feb-05-2019, 03:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get datetime from numeric format field klllmmm 3 2,022 Nov-06-2021, 03:26 PM
Last Post: snippsat
  Exporting dataframes to excel without loosing datetime format Rafa 0 1,252 Oct-27-2021, 10:42 AM
Last Post: Rafa
  Datetime format issue with z sks3286 2 7,449 Apr-07-2020, 12:26 PM
Last Post: sks3286
  openpyxl, if value in cell then change format genderbee 1 5,290 Nov-05-2019, 01:37 PM
Last Post: genderbee
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str' findbikash 2 9,658 Sep-18-2019, 08:32 AM
Last Post: buran
  Change Time Format in Python bluethundr 2 2,720 Mar-04-2019, 09:13 PM
Last Post: bluethundr
  Reading and writing to text file has format change cheerful 3 3,739 Dec-21-2017, 07:53 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020