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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will Rocisky

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

    Actually I am trying to save both date and time in one cell but they
    are given separately by user.
  • Steven D'Aprano

    #2
    Re: How to concatenate datetime.date object and datetime.timeob ject

    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.dateti me() object:
    >>date = datetime.date(2 008, 8, 5)
    >>time = datetime.time(1 9, 54)
    >>datetime.date time.combine(da te, time)
    datetime.dateti me(2008, 8, 5, 19, 54)

    I discovered this by opening an interactive session and calling
    help(datetime).


    --
    Steven

    Comment

    • Thomas Wright

      #3
      Re: How to concatenate datetime.date object and datetime.time object

      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.dateti me.combine(d, t).

      HTH!

      --
      I'm at CAMbridge, not SPAMbridge

      Comment

      Working...