0
votes

I have a column in my spark dataframe called "Fiscal Month" in which the values are "January 2015","February 2015" and so on. So the format is "Month Year" which has the datatype String.

How do I convert this to a date format using Spark SQL?

1

1 Answers

3
votes

using unix_timestamp something like

import org.apache.spark.sql.functions.unix_timestamp

df.select(unix_timestamp($"Fiscal Month","MMMM yy"))

See functions object.