V
V
Vladimir Golub2021-05-31 16:14:09
MySQL
Vladimir Golub, 2021-05-31 16:14:09

Why is MySQL throwing a date out of range?

I use TypeORM for requests.

Before inserting into the query, I have the following values ​​\u200b\u200bof the end and beginning of the interval:

{ startTime: '2021-05-31 00:00:00' }
{ endTime: '2021-05-31 23:59:59' }


query.andWhere('cm.time >= :startTime AND cm.time <= :endTime', { startTime: startTime, endTime: endTime });


But dates are selected from "2021-05-30T23:00:00.000Z" ? How to solve this problem?

UPD:
Tried to send such result the same
{ startTime: '2021-05-31T00:00:00.000' }
{ endTime: '2021-05-31T23:59:59.999' }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Golub, 2021-06-01
@RazerVG

Solved the problem at the typeorm level

@Column({
  type: 'date',
  name: 'time'
})
time: string;

/**
     * Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects.
     * Can be true/false or an array of type names to keep as strings.
     */
    readonly dateStrings?: boolean | string[];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question