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.
#1
I have pulled date from excel to python , when I print the date in Python it shows like "2019-11-28 00:00:00" , which is not what I want . I want to again pass this date to python program in format 24-Nov-2019. How to do it ?
Reply
#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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 231 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 605 Jan-20-2024, 04:45 AM
Last Post: 1418
  How to see the date of installation of python modules. newbieAuggie2019 4 1,603 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Date format and past date check function Turtle 5 4,257 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,236 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,860 Dec-06-2020, 04:14 PM
Last Post: Divya577
  python sort date beginner2020 13 6,049 Nov-06-2020, 03:30 PM
Last Post: beginner2020
  How to add date and years(integer) to get a date NG0824 4 2,866 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,131 Jul-04-2019, 06:54 PM
Last Post: Axel_Erfurt
  How to change existing date to current date in a filename? shankar455 1 2,296 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