Time Format

Liliana
Liliana βšͺ️

Hello,

I am combining date and time in one column but once is combined the date format is ok but my time format is all zeros. is there something I am missing?


Thank you!

Best Answers

  • GrantSmith
    GrantSmith Indiana πŸ”΄
    Accepted Answer

    How are you combining your date and time fields? What format is your time field in?

  • GrantSmith
    GrantSmith Indiana πŸ”΄
    edited September 24 Accepted Answer

    Try this:

    DATE_ADD(`Timecard_Pay_Date`,  interval time_to_sec(`Time_Out`) second)
    

    Its converting your time string to the number of seconds and then adding that to your date since dates have an inherent time of midnight

  • Liliana
    Liliana βšͺ️
    Accepted Answer

    Thanks Grant!

Answers

  • Liliana
    Liliana βšͺ️

    Thanks Grant for your prompt answer. My date is formatted as date. After I combined the date and time, i changed it to timestamp.


  • GrantSmith
    GrantSmith Indiana πŸ”΄

    What is the format of your Time_Out field?

  • Liliana
    Liliana βšͺ️

    As a time stamp i got the example above.

    I changed it to text and now i got this:


    I need to get it in this format:

    Thanks again Grant.

  • tejusarora
    tejusarora βšͺ️
    edited September 24

    @Liliana If you have access to ETL 2.0 then you can add a formula tile with Date and combine with a couple of functions as shown below:

    Raw data: Thu Sep 02 00:00:00 GMT 2021 07:49 AM

    Output: 2021-09-02 07:49:00 (format in timestamp)


    Formula: timestamp(CONCAT(split_part(`Date`,' ',3), ' ', split_part(`Date`,' ',2), ' ',split_part(`Date`,' ',6),' ',split_part(`Date`,' ',7),' ',split_part(`Date`,' ',8),' ',split_part(`Date`,' ',5)))


    The idea here is to rearrange texts in your string in a format that can be recognized by domo and converted to timestamp. You can also use Split Columns tile and combine tiles to do the same.

    Best, TJ

  • Hi @Liliana ,

    Rather than trying to combine the date and time as text, I would suggest using this approach:

    1. Create a duplicate of the Time_Out column using a Combine Columns tile, using "None" as your character separating and selecting only Time_Out in the column list (Do not check the box to remove the columns being combined)
    2. Your new column will default to text, so use a Set Column Type tile to change it to Date (Month First)
    3. Add a Date Operations tile to calculate the number of minutes after midnight your timestamp is by using the "Difference between dates" operation, Minutes as your unit of measurement, and calculating the original Time_Out column minus the date only copy you just made
    4. Use another Date Operations tile to add that number of minutes to the Timecard_Pay_Day column by selecting the "Add to date" operation with Minutes as your unit of measurement. Add Timecard_Pay_Day plus the minutes column you calculated in the previous step

    Hope this helps!

  • Liliana
    Liliana βšͺ️

    Thank you @tejusarora and @MichelleH for your answers. I will try your suggestions.

  • GrantSmith
    GrantSmith Indiana πŸ”΄

    Glad I could help @Liliana. If you could accept my answer so others can find it easier I'd appreciate it! Thanks.