Cypress/tedious/mssql Conversion failed when converting date and/or time from character string

129 views Asked by At

I get this error when I try to execute a simple SQL statement that properly works on the db.

The table:

hd_date     | hd_name
2025-04-21  | Ostermontag
2025-06-09  | Pfingstmontag

This works:

var sql = 'select hd_name from holidays '

cy.sqlServer(sql).then(function (result) {
  
  cy.log(result)

})

But as soon I include the hd_date I get the error. This

var sql = 'select hd_date, hd_name from holidays '

and this

var sql = 'select hd_name from holidays where year(hd_date) = 2025'

doesn't work.

Any ideas?

1

There are 1 answers

1
Mike On

I found the solution. Tedious loggin to the SQL server with its own default language / time settings: us_english and mdy. You need to change it in the options. In my case with cypress in the file cypress.config.js

  config.db = {
    "userName": "xxx",
    "password": "xxx,
    "server": "xxx",
    "options": {
      "database": "xxx",
      "encrypt": true,
      "rowCollectionOnRequestCompletion": true,
      "dateFormat": "dmy",
      "language": "Deutsch",
      "datefirst": 1
    }
  }