# Easy way to convert to datetime?

**URL:** <https://forum.seatable.com/t/easy-way-to-convert-to-datetime/2005>\
**Category:** Formulas\
**Tags:** date-and-time\
**Created:** [January 21, 2023, 10:35am UTC](https://forum.seatable.com/t/easy-way-to-convert-to-datetime/2005 "2023-01-21T10:35:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkDk7](https://forum.seatable.com/user_avatar/forum.seatable.com/akdk7/32/2186_2.png) [@AkDk7](https://forum.seatable.com/u/AkDk7)\
**Post date:** [January 21, 2023, 10:35am UTC](https://forum.seatable.com/t/easy-way-to-convert-to-datetime/2005/1 "2023-01-21T10:35:37Z")

</div>

Hi.

I’ve tried to find a solution for converting string datetime values to the data type datetime.

I’m having this string “21.01.2023, 09:11” and you can see there is comma between the date and time string. Of course SeaTable cannot recognize this as valid. So since there is no function to convert such a string, after I had to get rid of the comma, to convert it to a valid datetime data type, so I figured out a formula to do this.

![grafik](https://forum.seatable.io/uploads/default/original/2X/d/d2c581f5a6c83c345099b305c854e02b804e5275.png)

In the column Datum is just used a `substitute({Name}, ',', '', 1)` to get rid of the comma but it would not be converted to valid datetime by SeaTable.

I used this formula in the column Datum2:

```auto
dateAdd(
  dateAdd(
    date(
      right(left({Name}, 10), 4),
      right(left({Name}, 5), 2),
      left({Name}, 2)
    ) & ' 00:00:00',
    value(left(right({Name}, 5), 2)), 
    'hours'
  ),
  value(right({Name}, 2)),
  'minutes'
)

```

**How does it work?**  
In the first step it converts the date to a valid data type. The thing with the time value ‘00:00:00’ I will explain later. Then I add the hours with the inner dateAdd function. After this step I run this values again through a dateAdd function to add the minutes. Now we come to the funny part: if I leave the string ‘00:00:00’ away, SeaTable will not recognize it as a date and time formatting even if I add hours, minutes or seconds with dateAdd to it.

Is there a simplier way to convert datetime string to a valid datetime type in SeaTable?

Cheers  
AkDk7
