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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해