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
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
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.
add a comment |
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
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 dodatetime.and press tab, that should give you a list to pick from likeday,hour,microsecondsetc...
– Guimoute
Mar 20 at 15:03
1
Possible duplicate of Date Time split in python
– Giovanni Cappelletti
Mar 20 at 15:06
add a comment |
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
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
python datetime
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.
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 dodatetime.and press tab, that should give you a list to pick from likeday,hour,microsecondsetc...
– Guimoute
Mar 20 at 15:03
1
Possible duplicate of Date Time split in python
– Giovanni Cappelletti
Mar 20 at 15:06
add a comment |
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 dodatetime.and press tab, that should give you a list to pick from likeday,hour,microsecondsetc...
– 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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 likeday,hour,microsecondsetc...– Guimoute
Mar 20 at 15:03
1
Possible duplicate of Date Time split in python
– Giovanni Cappelletti
Mar 20 at 15:06