This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: fractional day attribute in datetime class
Type: enhancement Stage: resolved
Components: Versions: Python 3.3
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: belopolsky Nosy List:, belopolsky, daniel.urban
Priority: normal Keywords:

Created on 2011-08-17 16:15 by, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg142286 - (view) Author: Miguel de Val Borro ( Date: 2011-08-17 16:15
It would be useful to have a fractional day method in datetime.datetime
that returns a float object calculated from the day, hour, minute, second, and microseconds. Fractional days in UTC are often used in science, in particular to record astronomical observations.
msg142503 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-08-19 22:53
You can easily get the fractional day value using existing functionality:

>>> from datetime import *
>>> (datetime(2011,8,15,18,30) -  datetime(2011,8,13,12,0)) / timedelta(1)
>>> (datetime(2011,8,15,18,30) -  datetime(1970,1,1)) / timedelta(1)

In some sense this request is a duplicate of issue2736.
msg142553 - (view) Author: Miguel de Val Borro ( Date: 2011-08-20 18:49
Thanks, I need the fractional day added to the ordinal day of the month. Using the timedelta division it would be:

>>> from __future__ import division
>>> dt = datetime.datetime(2008, 5, 8, 13, 35, 41, 567777)
>>> + (dt-datetime.datetime(dt.year, dt.month,

Then it simply becomes a one line function so I'm closing this ticket.
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56981
2011-08-20 pending -> closed

messages: + msg142553
2011-08-19 22:53:10belopolskysetstatus: open -> pending

assignee: belopolsky

nosy: + belopolsky
messages: + msg142503
resolution: rejected
stage: resolved
2011-08-18 08:05:23daniel.urbansetnosy: + daniel.urban

versions: + Python 3.3, - Python 2.7