Tableau Prep is very similar to Tableau in calculation syntax (almost identical), but this is one case where there is a difference. Dates cannot be hard-coded by enclosing in hash-marks in Tableau Prep (e.g. #01/01/2018# is not a valid date). Instead, look at replacing those in your code with the MAKEDATE() function or DATEPARSE().
Hope that helps!