I’m not entirely sure if this is what you’re asking, but you could just use the
datediff function:
val df2 = df.withColumn("ID”, datediff($"end", $"start”))
If you want it formatted as {n}D then:
val df2 = df.withColumn("ID", concat(datediff($"end", $"start"),lit("D")))
Thanks,
Silvio
From:
I have a time stamping table which has data like
No of Days ID
11D
22D
and so on till 30 days
Have another Dataframe with
start date and end date
I need to get the difference between these two days and get the ID from
Time Stamping table and do With Column .