We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Combine Date & Time Fields



  • Avatar
    Adrian Williams

    You do not state the technical data type of the two fields. However, as you state the format I'm assuming both of the fields have a string or unicode data type, e.g. they are similar to this when viewed in the Data Viewer:


    The simplest way is to use the Modify Fields node to convert the event_date field to date type and the event_time field to a time type:


    Resulting in the following:


    Note that you will need to select the appropriate format for the ev_date from the suggested format list:


    In the case of the ev_time field the suggestions list does not contain the HH:MM format so you will need to select the HH:mm:ss format and then edit the format statement to remove the seconds element.


    The Calculate Fields node can then be used to derive a datetime data type field from the date and time fields. In this case the expression utilizes the datetime.datetime.combine() function:


    The ev_datetime variable has a datetime data type. You can then use another expression to create the string representation of the datetime value using the str() function, resulting in the following:



    If require, the above transformations can also be achieved (in a more long-hand way) using the Transform node:

    Note that you either need to ensure there are no Null values in the event_date and event_time fields or include appropriate code to handle the situation where either field is Null in a record.


    Comment actions Permalink
  • Avatar
    Joshua Campbell

    Thanks Adrian. That worked great!

    Comment actions Permalink

Please sign in to leave a comment.