How to extract Date from TimeStamp1, Time from TimeStamp2, and then combine the two?

So I have two fields, "DateV2" and "EventTime V2". I am trying to extract out the Date portion (2018-11-16) from "DateV2" and combining that with the Time portion (12:07:00) from "EventTime V2".

I am trying to do this in Magic 2.0.

Here is my beast mode/formula in the Formula Tile:

DATE_FORMAT(CONCAT(DATE_FORMAT(`Date V2`,'%Y-%m-%d'), ' ', DATE_FORMAT(`EventTime V2`,'%H:%i:%s' )),'%Y-%m-%d %H:%i:%s') ELSE `Date V2` END

The preview of the formula works. However, when I try to run this, I run into an error:

I am not sure why the preview works when it is able to recognize 18:00:00 as a timestamp but 15:40:00 (in the error) does not work.

Anyone spot anything wrong? Or, is there a simpler way of extracting these two parts out and combining them?

Appreciate any help, thank you!

Best Answer

  • MarkSnodgrass
    MarkSnodgrass Portland, Oregon 🥷
    Answer ✓

    Try this:

    Use the DATE() function to extract the date from the field you want just the date

    Use the TIME() function to extract the time from the field you want just the time

    Use the ADDTIME() function to add the two together ADDTIME('dt','tm')

    I did a quick test in Magic ETL and it worked for me. I had them each separated for testing, but you should be fine wrapping it all into one like this:


    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.


  • Ritwik
    Ritwik Atlanta 🟡

    Hi @MarkSnodgrass

    Thanks for the help -- that is definitely simpler and easier to follow!

    I realized that the "EventTime V2" field I was referencing in my original beast mode was NOT datetime, but rather a string (due to an earlier transformation).