Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date to integer?
#1
HI everyone,

I am looking to convert a date to integer, how do I go about this? column below
Qtr-Year
Mar-90	
Jun-90
Sep-90
Dec-90
Mar-91
do I first need to change the date format to '031990' etc then change it to a str then interger?

I appreciate any help
Thanks
Reply
#2
Convert it into a datetime object:
See here: https://python-forum.io/Thread-help-with...-to-Python

Or convert into a time object:
See here: https://docs.python.org/3.7/library/time.html
Reply
#3
better if year is firs and then month, e.g. 9003, 9006, etc. this will allow to sort the integers in correct order
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 242 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 613 Jan-20-2024, 04:45 AM
Last Post: 1418
  Date format and past date check function Turtle 5 4,271 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,240 Feb-06-2021, 10:48 PM
Last Post: eddywinch82
  How to add date and years(integer) to get a date NG0824 4 2,877 Sep-03-2020, 02:25 PM
Last Post: NG0824
  How to subtract the DayOfWeek from date from a integer? DarkCoder2020 2 2,126 May-27-2020, 09:56 PM
Last Post: bowlofred
  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,298 Apr-17-2019, 01:53 PM
Last Post: snippsat
  Date format conversion "/Date(158889600000)/" lbitten 2 2,839 Nov-29-2018, 02:14 PM
Last Post: Larz60+
  datetime.date() - TypeError: an integer is required (got type str) bisoftware 7 30,996 Jan-30-2018, 08:05 PM
Last Post: buran

Forum Jump:

User Panel Messages

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