I have tried convert a string ddMMyy using to_date function to yyyyMMdd
But the spark cast the date to 1900 year
for exemple: I tried cast 150545 to 20450515 but got 19450515
#my_date = '150545'
df = df.withColumn('sorce_format', lit('ddMMyy'))
df = df.withColumn('target_format', lit('yyyyMMdd'))
def cast_date_fields(df ):
df = df.withColumn(
"data_ok",
expr("to_date(to_date(mydate,sorce_format), target_format)").cast('String'))
return df
Using jupter notebook the cast working fine but using aws glue the cast convert the date to 1900 year.