Python Forum
Formatting a date time string read from a csv file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formatting a date time string read from a csv file
#4
Okay. In that case, you can use string slicing:

my_datetime = '2023-06-15 07:26:50'

my_date = my_datetime[0:10]

print(my_date)
Output:
2023-06-15
DosAtPython likes this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Messages In This Thread
RE: Formatting a date time string read from a csv file - by rob101 - Jun-19-2023, 12:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting DateTime string and and converting it from AM/PM to 24 hours tester_V 2 255 Jun-08-2024, 05:16 PM
Last Post: tester_V
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 476 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Compare current date on calendar with date format file name Fioravanti 1 465 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Date Time Series Help...Please spra8560 2 529 Feb-01-2024, 01:38 PM
Last Post: spra8560
  Python date format changes to date & time 1418 4 901 Jan-20-2024, 04:45 AM
Last Post: 1418
  Recommended way to read/create PDF file? Winfried 3 3,154 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,901 Nov-09-2023, 10:56 AM
Last Post: mg24
  Need to replace a string with a file (HTML file) tester_V 1 940 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Downloading time zone aware files, getting wrong files(by date))s tester_V 9 1,380 Jul-23-2023, 08:32 AM
Last Post: deanhystad
  read file txt on my pc to telegram bot api Tupa 0 1,309 Jul-06-2023, 01:52 AM
Last Post: Tupa

Forum Jump:

User Panel Messages

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