Time Format

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 Coach
    Answer ✓

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

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • GrantSmith
    GrantSmith Coach
    edited September 2021 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

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Liliana
    Liliana Member
    Answer ✓

    Thanks Grant!

Answers

  • GrantSmith
    GrantSmith Coach
    Answer ✓

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

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thanks Grant for your prompt answer. My date is formatted as date. After I combined the date and time, i changed it to timestamp.


  • What is the format of your Time_Out field?

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • 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 Member
    edited September 2021

    @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!

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

  • GrantSmith
    GrantSmith Coach
    edited September 2021 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

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Liliana
    Liliana Member
    Answer ✓

    Thanks Grant!

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

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**