Python Forum
Date from from excel to Python.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date from from excel to Python.
#2
Is it a datetime object or is it a string?
If it is a string you will have to slice it and output it in the order you want.
If it is a datetime object you may want to format it using the strftime() method.
from datetime import datetime
date_and_time = datetime.now()

print(date_and_time.strftime("%d-%b-%Y"))
Output:
24-Nov-2019
Reply


Messages In This Thread
Date from from excel to Python. - by atp_13 - Nov-24-2019, 10:38 AM
RE: Date from from excel to Python. - by ibreeden - Nov-24-2019, 12:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 279 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 660 Jan-20-2024, 04:45 AM
Last Post: 1418
  How to see the date of installation of python modules. newbieAuggie2019 4 1,663 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Date format and past date check function Turtle 5 4,330 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 2,256 Feb-06-2021, 10:48 PM
Last Post: eddywinch82
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 1,876 Dec-06-2020, 04:14 PM
Last Post: Divya577
  python sort date beginner2020 13 6,161 Nov-06-2020, 03:30 PM
Last Post: beginner2020
  How to add date and years(integer) to get a date NG0824 4 2,909 Sep-03-2020, 02:25 PM
Last Post: NG0824
  Substracting today's date from a date in column of dates to get an integer value firebird 1 2,145 Jul-04-2019, 06:54 PM
Last Post: Axel_Erfurt
  How to change existing date to current date in a filename? shankar455 1 2,316 Apr-17-2019, 01:53 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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