Add Number of days column to Date Column in same dataframe for Spark Scala App
No need to use an UDF, you can do it using an SQL expression: val newDF = df.withColumn(“new_date”, expr(“date_add(current_date,days)”))
No need to use an UDF, you can do it using an SQL expression: val newDF = df.withColumn(“new_date”, expr(“date_add(current_date,days)”))
You may use something like the strtotime() function to add something to the current timestamp. $new_time = date(“Y-m-d H:i:s”, strtotime(‘+5 hours’)). If you need variables in the function, you must use double quotes then like strtotime(“+{$hours} hours”), however better you use strtotime(sprintf(“+%d hours”, $hours)) then.