Payperiod from SQL

Unsuccessful return in dynamics