Skip to content
Advertisement

Extract time from Date Time as a separate column

My table looks like this –

DateTime ID
2010-12-01 08:26:00 34
2010-12-01 09:41:00 42

I want to extract the time from DateTime and create a third column of it and then group it with frequency counts. Is there a way to do this in SQL? I’m using Apache Spark with inline SQL. I have achieved the equivalent using Spark functions like this –

Advertisement

Answer

If you want to do it in SQL, you can do:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement