Answer the question
In order to leave comments, you need to log in
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 });
{ 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
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 questionAsk a Question
731 491 924 answers to any question