I have a pyspark data frame that I am going to convert one of its column( which is in timestamp ) into Jalali date.
My data frame:
| Name | CreationDate |
|---|---|
| Sara | 2022-01-02 10:49:43 |
| Mina | 2021-01-02 12:30:21 |
I want the following result:
| Name | CreationDate |
|---|---|
| Sara | 1400-10-12 10:49:43 |
| Mina | 1399-10-13 12:30:21 |
I try the following code, but It does not work, I cannot find a way to convert the date and time:
df_etl_test_piko1.select(jdatetime.datetime.col('creationdate').strftime("%a, %d %b %Y %H:%M:%S"))
You need to define UDF like this:
Then applying to your example: