I'm trying to change date format from yyyy-MM-dd
to yyyy-MM
.
Ultimately I want to be able to sum and group by month. So far the only working solution I found is adding concat(year(join_data["firstVisit"]), lit("-"), month(join_data["firstVisit"])).alias('firstVisitMonth')
in my select statement but then it return the column as a string and I can't sort it correctly.
Try date_format
:
date_format(join_data["firstVisit"], 'yyyy-MM')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.