Date compare is null

Hi, I want to have a ri!startDate, I will use the a!isNotNull function to display some warning message if the ri!startDate is null else will retrieve the weekday(ri!startDate)

but I keep encountering the error message such as Cannot sub incompatible operands of type Date and type Text.

below here is my code for the interface

a!localVariables(
  local!weeknum:if(a!isNotNullOrEmpty(ri!startDate),weeknum(ri!startDate),{}),
  local!day:if(a!isNotNullOrEmpty(ri!startDate),day(ri!startDate),{}),
  local!month:if(a!isNotNullOrEmpty(ri!startDate),month(ri!startDate),{}),
  local!year:if(a!isNotNullOrEmpty(ri!startDate),year(ri!startDate),{}),
  local!dayofWeek:if(ri!startDate=null(),"Please Select a Date ", weekday(ri!startDate)-1),
  local!startWeekDay:if(local!dayofWeek<>1,ri!startDate-local!dayofWeek+1,{}),
  local!endWeekDay:local!startWeekDay+4,
  local!monday:local!startWeekDay,
  local!tuesday:local!startWeekDay+1,
  local!wednesday:local!startWeekDay+2,
  local!thursday:local!startWeekDay+3,
  local!friday:local!startWeekDay+4,
  
  
a!formLayout(
  label: "Form",
  contents: {
    a!sectionLayout(
      contents: {
        a!dateField(
          label: "Start Date",
          labelPosition: "ABOVE",
          value:today(),
          saveInto: ri!startDate,
          validations: {}
        )
      }
    ),
    a!integerField(
      label: local!monday,
      labelPosition: "JUSTIFIED",
      saveInto: {},
      refreshAfter: "UNFOCUS",
      validations: {}
    ),
    a!integerField(
      label: local!tuesday,
      labelPosition: "JUSTIFIED",
      saveInto: {},
      refreshAfter: "UNFOCUS",
      validations: {}
    )

  },
  buttons: a!buttonLayout(
    primaryButtons: {
      a!buttonWidget(
        label: "Submit",
        submit: true,
        style: "PRIMARY"
      )
    },
    secondaryButtons: {
      a!buttonWidget(
        label: "Cancel",
        value: true,
        saveInto: ri!cancel,
        submit: true,
        style: "NORMAL",
        validate: false
      )
    }
  )
)
)

  Discussion posts and replies are publicly visible