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

Discussion in 'Python' started by Will Rocisky, Aug 5, 2008.

  1. Will Rocisky

    Will Rocisky Guest

    Actually I am trying to save both date and time in one cell but they
    are given separately by user.
    Will Rocisky, Aug 5, 2008
    #1
    1. Advertising

  2. Re: How to concatenate datetime.date object and datetime.timeobject

    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
    Steven D'Aprano, Aug 5, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,196
    Michael Borgwardt
    May 30, 2004
  2. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    685
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  3. Tim Peters
    Replies:
    0
    Views:
    518
    Tim Peters
    Sep 9, 2003
  4. Keith Cochrane
    Replies:
    2
    Views:
    597
    Keith Cochrane
    Aug 6, 2006
  5. Carlos

    Concatenate/De-Concatenate

    Carlos, Oct 12, 2012, in forum: VHDL
    Replies:
    10
    Views:
    854
Loading...

Share This Page