Search code examples
sqlhivetimestamphiveql

how to round timestamp to day in HIVE?


I have a string value like '2020-10-01T02:02:50.918+03:00'. How can I get value like this: 2020-10-01 00:00:00.000 in timestamp datatype in Hive?


Solution

  • Use substr to get yyyy-MM-dd, then use timestamp construct.

    Demo:

    select timestamp(substr('2020-10-01T02:02:50.918+03:00',1,10))
    

    Result:

    2020-10-01 00:00:00.0