How to split Python datetime object to date and time numbers?Date Time split in pythonHow to return only the Date from a SQL Server DateTime datatypeHow can I safely create a nested directory in Python?How do you split a list into evenly sized chunks?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonHow do I get the number of elements in a list in Python?How do I concatenate two lists in Python?Find objects between two dates MongoDBHow to make an unaware datetime timezone aware in python

Open a doc from terminal, but not by its name

anything or something to eat

Divine apple island

Diode in opposite direction?

Is it possible to use .desktop files to open local pdf files on specific pages with a browser?

Proving a function is onto where f(x)=|x|.

Do varchar(max), nvarchar(max) and varbinary(max) columns affect select queries?

How can "mimic phobia" be cured or prevented?

What is the difference between "Do you interest" and "...interested in" something?

Greco-Roman egalitarianism

Reply 'no position' while the job posting is still there

MAXDOP Settings for SQL Server 2014

How must one send away the mother bird?

We have a love-hate relationship

Two-sided logarithm inequality

Database accidentally deleted with a bash script

Can we have a perfect cadence in a minor key?

Can a Necromancer reuse the corpses left behind from slain undead?

Journal losing indexing services

Flux received by a negative charge

Engineer refusing to file/disclose patents

A social experiment. What is the worst that can happen?

Is Asuka Langley-Soryu disgusted by Shinji?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?



How to split Python datetime object to date and time numbers?


Date Time split in pythonHow to return only the Date from a SQL Server DateTime datatypeHow can I safely create a nested directory in Python?How do you split a list into evenly sized chunks?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonHow do I get the number of elements in a list in Python?How do I concatenate two lists in Python?Find objects between two dates MongoDBHow to make an unaware datetime timezone aware in python













0















I would like to store a Python datetime object as date number and time number in a database. How do you split the datetime object into date and time numbers ?



Today = datetime.today()
TodayNumber = Today.timestamp() #-- this returns a FLOAT

Day = Today.date() #- date object
Time = Today.time() #- time object

DayNumber = Day.whatfuntion() #- internal represtation for date in INTEGER
TimeNumber = Time.whatfundtion() #- internal representation for time in INTEGER


Update - the slution for date is to convert to the gregorial oridnal



DayNumber = Day.toordinal() #- internal represtation for date in INTEGER









share|improve this question









New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • In what format do you want the output?, please give an example.

    – Mntfr
    Mar 20 at 15:00






  • 1





    Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

    – Kondasamy Jayaraman
    Mar 20 at 15:00











  • Format it once for just the date, and once for just the time parts?

    – tobias_k
    Mar 20 at 15:01












  • In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

    – Guimoute
    Mar 20 at 15:03






  • 1





    Possible duplicate of Date Time split in python

    – Giovanni Cappelletti
    Mar 20 at 15:06















0















I would like to store a Python datetime object as date number and time number in a database. How do you split the datetime object into date and time numbers ?



Today = datetime.today()
TodayNumber = Today.timestamp() #-- this returns a FLOAT

Day = Today.date() #- date object
Time = Today.time() #- time object

DayNumber = Day.whatfuntion() #- internal represtation for date in INTEGER
TimeNumber = Time.whatfundtion() #- internal representation for time in INTEGER


Update - the slution for date is to convert to the gregorial oridnal



DayNumber = Day.toordinal() #- internal represtation for date in INTEGER









share|improve this question









New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • In what format do you want the output?, please give an example.

    – Mntfr
    Mar 20 at 15:00






  • 1





    Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

    – Kondasamy Jayaraman
    Mar 20 at 15:00











  • Format it once for just the date, and once for just the time parts?

    – tobias_k
    Mar 20 at 15:01












  • In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

    – Guimoute
    Mar 20 at 15:03






  • 1





    Possible duplicate of Date Time split in python

    – Giovanni Cappelletti
    Mar 20 at 15:06













0












0








0








I would like to store a Python datetime object as date number and time number in a database. How do you split the datetime object into date and time numbers ?



Today = datetime.today()
TodayNumber = Today.timestamp() #-- this returns a FLOAT

Day = Today.date() #- date object
Time = Today.time() #- time object

DayNumber = Day.whatfuntion() #- internal represtation for date in INTEGER
TimeNumber = Time.whatfundtion() #- internal representation for time in INTEGER


Update - the slution for date is to convert to the gregorial oridnal



DayNumber = Day.toordinal() #- internal represtation for date in INTEGER









share|improve this question









New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I would like to store a Python datetime object as date number and time number in a database. How do you split the datetime object into date and time numbers ?



Today = datetime.today()
TodayNumber = Today.timestamp() #-- this returns a FLOAT

Day = Today.date() #- date object
Time = Today.time() #- time object

DayNumber = Day.whatfuntion() #- internal represtation for date in INTEGER
TimeNumber = Time.whatfundtion() #- internal representation for time in INTEGER


Update - the slution for date is to convert to the gregorial oridnal



DayNumber = Day.toordinal() #- internal represtation for date in INTEGER






python datetime






share|improve this question









New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago







CW Gan













New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 20 at 14:58









CW GanCW Gan

11




11




New contributor




CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






CW Gan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • In what format do you want the output?, please give an example.

    – Mntfr
    Mar 20 at 15:00






  • 1





    Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

    – Kondasamy Jayaraman
    Mar 20 at 15:00











  • Format it once for just the date, and once for just the time parts?

    – tobias_k
    Mar 20 at 15:01












  • In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

    – Guimoute
    Mar 20 at 15:03






  • 1





    Possible duplicate of Date Time split in python

    – Giovanni Cappelletti
    Mar 20 at 15:06

















  • In what format do you want the output?, please give an example.

    – Mntfr
    Mar 20 at 15:00






  • 1





    Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

    – Kondasamy Jayaraman
    Mar 20 at 15:00











  • Format it once for just the date, and once for just the time parts?

    – tobias_k
    Mar 20 at 15:01












  • In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

    – Guimoute
    Mar 20 at 15:03






  • 1





    Possible duplicate of Date Time split in python

    – Giovanni Cappelletti
    Mar 20 at 15:06
















In what format do you want the output?, please give an example.

– Mntfr
Mar 20 at 15:00





In what format do you want the output?, please give an example.

– Mntfr
Mar 20 at 15:00




1




1





Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

– Kondasamy Jayaraman
Mar 20 at 15:00





Please check this - stackoverflow.com/questions/33810980/date-time-split-in-python/… Possible duplicate

– Kondasamy Jayaraman
Mar 20 at 15:00













Format it once for just the date, and once for just the time parts?

– tobias_k
Mar 20 at 15:01






Format it once for just the date, and once for just the time parts?

– tobias_k
Mar 20 at 15:01














In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

– Guimoute
Mar 20 at 15:03





In addition to what @KondasamyJayaraman said, if you need just one of the values you can do datetime. and press tab, that should give you a list to pick from like day, hour, microseconds etc...

– Guimoute
Mar 20 at 15:03




1




1





Possible duplicate of Date Time split in python

– Giovanni Cappelletti
Mar 20 at 15:06





Possible duplicate of Date Time split in python

– Giovanni Cappelletti
Mar 20 at 15:06












1 Answer
1






active

oldest

votes


















1














Depends on what you mean by "date number" and "time number". But the following may solve your issue:



>>> from datetime import datetime
>>> year, month, day, hour, minute, second, *_ = datetime.now().timetuple()


See https://docs.python.org/3/library/datetime.html#datetime.date.timetuple for documentation.






share|improve this answer























  • I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

    – CW Gan
    Mar 21 at 13:42












  • This is what u need, a timetuple splits DateTime object to several integers

    – Dmitrii
    Mar 21 at 14:54











  • I found the answer for date - cnvert it to Gregorian ordinal

    – CW Gan
    2 days ago











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






CW Gan is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55263868%2fhow-to-split-python-datetime-object-to-date-and-time-numbers%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Depends on what you mean by "date number" and "time number". But the following may solve your issue:



>>> from datetime import datetime
>>> year, month, day, hour, minute, second, *_ = datetime.now().timetuple()


See https://docs.python.org/3/library/datetime.html#datetime.date.timetuple for documentation.






share|improve this answer























  • I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

    – CW Gan
    Mar 21 at 13:42












  • This is what u need, a timetuple splits DateTime object to several integers

    – Dmitrii
    Mar 21 at 14:54











  • I found the answer for date - cnvert it to Gregorian ordinal

    – CW Gan
    2 days ago
















1














Depends on what you mean by "date number" and "time number". But the following may solve your issue:



>>> from datetime import datetime
>>> year, month, day, hour, minute, second, *_ = datetime.now().timetuple()


See https://docs.python.org/3/library/datetime.html#datetime.date.timetuple for documentation.






share|improve this answer























  • I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

    – CW Gan
    Mar 21 at 13:42












  • This is what u need, a timetuple splits DateTime object to several integers

    – Dmitrii
    Mar 21 at 14:54











  • I found the answer for date - cnvert it to Gregorian ordinal

    – CW Gan
    2 days ago














1












1








1







Depends on what you mean by "date number" and "time number". But the following may solve your issue:



>>> from datetime import datetime
>>> year, month, day, hour, minute, second, *_ = datetime.now().timetuple()


See https://docs.python.org/3/library/datetime.html#datetime.date.timetuple for documentation.






share|improve this answer













Depends on what you mean by "date number" and "time number". But the following may solve your issue:



>>> from datetime import datetime
>>> year, month, day, hour, minute, second, *_ = datetime.now().timetuple()


See https://docs.python.org/3/library/datetime.html#datetime.date.timetuple for documentation.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 20 at 15:09









Martin IndraMartin Indra

113




113












  • I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

    – CW Gan
    Mar 21 at 13:42












  • This is what u need, a timetuple splits DateTime object to several integers

    – Dmitrii
    Mar 21 at 14:54











  • I found the answer for date - cnvert it to Gregorian ordinal

    – CW Gan
    2 days ago


















  • I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

    – CW Gan
    Mar 21 at 13:42












  • This is what u need, a timetuple splits DateTime object to several integers

    – Dmitrii
    Mar 21 at 14:54











  • I found the answer for date - cnvert it to Gregorian ordinal

    – CW Gan
    2 days ago

















I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

– CW Gan
Mar 21 at 13:42






I ahve the date and time in a datetime object and would like to store date and time as two INTEGER in a database, the datetime,timestamp() equivalent for date and time.

– CW Gan
Mar 21 at 13:42














This is what u need, a timetuple splits DateTime object to several integers

– Dmitrii
Mar 21 at 14:54





This is what u need, a timetuple splits DateTime object to several integers

– Dmitrii
Mar 21 at 14:54













I found the answer for date - cnvert it to Gregorian ordinal

– CW Gan
2 days ago






I found the answer for date - cnvert it to Gregorian ordinal

– CW Gan
2 days ago













CW Gan is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















CW Gan is a new contributor. Be nice, and check out our Code of Conduct.












CW Gan is a new contributor. Be nice, and check out our Code of Conduct.











CW Gan is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55263868%2fhow-to-split-python-datetime-object-to-date-and-time-numbers%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴