By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,403 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

How to concatenate datetime.date object and datetime.time object

P: n/a
Actually I am trying to save both date and time in one cell but they
are given separately by user.
Aug 5 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 05 Aug 2008 02:25:34 -0700, Will Rocisky wrote:
Actually I am trying to save both date and time in one cell but they are
given separately by user.
What's a "cell"?

I suggest building a datetime.datetime() object:
>>date = datetime.date(2008, 8, 5)
time = datetime.time(19, 54)
datetime.datetime.combine(date, time)
datetime.datetime(2008, 8, 5, 19, 54)

I discovered this by opening an interactive session and calling
help(datetime).
--
Steven
Aug 5 '08 #2

P: n/a
Will Rocisky wrote:
Actually I am trying to save both date and time in one cell but they
are given separately by user.
http://docs.python.org/lib/datetime-datetime.html indicates that the
function you're looking for is datetime.datetime.combine(d, t).

HTH!

--
I'm at CAMbridge, not SPAMbridge
Aug 5 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.