Using the Hive command regexp_extract
I am trying to change the following strings from:
201703170455 to 2017-03-17:04:55
and from:
2017031704555675 to 2017-03-17:04:55.0010
I am doing this in sparklyr trying to use this code that works with gsub in R:
newdf<-df%>%mutate(Time1 = regexp_extract(Time, "(....)(..)(..)(..)(..)", "\\1-\\2-\\3:\\4:\\5"))
and this code:
newdf<-df%>mutate(TimeTrans = regexp_extract("(....)(..)(..)(..)(..)(....)", "\\1-\\2-\\3:\\4:\\5.\\6"))
but does not work at all. Any suggestions of how to do this using regexp_extract?