Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1064417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:56:14+00:00 2026-05-16T18:56:14+00:00

I am new to python and am doing an export and import to a

  • 0

I am new to python and am doing an export and import to a new db.

I have a column on my export (to be imported) of strings for units of time, “20 minutes” “1.5 hours” “2 1/2 hours”, etc.

I tried googling but couldn’t really find any good phrases and kept coming up with information more related to datetime units rather than just units of time.

Fairly trivial to implement, but it seems like there is a good chance something exists.

Basically what I want to do is have the new DB just have the time in minutes, so I need to turn “1.5 hours” and “2 1/2 hours” into 90 and 150, respectively.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:56:14+00:00Added an answer on May 16, 2026 at 6:56 pm

    For the first two formats it looks like you can use the excellent 3rd-party module dateutil, e.g.:

    >>> from dateutil import parser
    >>> dt = parser.parse('1.5 hours') # returns `datetime` object
    >>> t = dt.time()
    >>> t
    datetime.time(1, 30)
    

    This doesn’t appear to work for “2 1/2 hours”, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to python and have no idea what I'm doing but
Hello I am a new user to Python and I am having problem doing
New to Python, have a simple, situational question: Trying to use BeautifulSoup to parse
Very new to python and can't understand why this isn't working. I have a
I am new to Python and have been studying its fundementals for 3 months
I'm a new to Python. I have installed Python 2.7 64 bit on Win7
I am new to Python and currently am doing some translations from 2.7 to
I'm quite new to python, so I'm doing my usual of going through Project
I am new to python and django and i have a question regarding the
Im new using Python, now I have a problem using ElementTree and read out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.