0

I have two date columns(format eg: 5/12/21) and need to find difference between them in days using pyspark. I tried but getting error.Need with Withcolumn.

date1 -  date2  =  result(in integer format)
datatatata
  • 23
  • 2
  • 6

1 Answers1

0

If you have column "date1" and column "date2"

import pyspark.sql.functions as F
df = df.withColumn("numDaysDiff", F.datediff(F.col("date1"), F.col("date2")))
WIT
  • 1,043
  • 2
  • 15
  • 32