Seconds field is not updating for datetime field in Database.

Certified Senior Developer

I have a datetime field as "2018-11-08T11:23:34+0000". I want to add this to database in a datetime type column. I'm using totime("11:23:34") but the 'seconds' field always showing '00'. How do I update 'seconds' field in database?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    The time() function works perfectly, you just need to split out the different parts of the string, which you can do with the split() function.

    See example I just got working in a try it now box on the documentation site: (note: I use integers in the example)

    concat(hour(time(11,23,34)), ":", minute(time(11,23,34)), ":", second(time(11,23,34))) which renders 11:23:34 as a string

    Though it normally doesn't output the seconds in the string it returns by default, they are stored in there for you to extract using the second() function.
Reply
  • 0
    Certified Lead Developer
    The time() function works perfectly, you just need to split out the different parts of the string, which you can do with the split() function.

    See example I just got working in a try it now box on the documentation site: (note: I use integers in the example)

    concat(hour(time(11,23,34)), ":", minute(time(11,23,34)), ":", second(time(11,23,34))) which renders 11:23:34 as a string

    Though it normally doesn't output the seconds in the string it returns by default, they are stored in there for you to extract using the second() function.
Children