casting issue on Temporary table

Viewed 66

I got error like:

1292 Truncated incorrect datetime value: '2021-11-30T18:30:00Z' 1292 Truncated incorrect datetime value: '2021-12-31T18:29:59Z'

I have just simply created one Temporary Table inside the Temporary table I have to get data from the date condition base. I have cast to date but somehow not proper work but I have replaced to '2021-12-31T18:29:59Z' to '2021-12-31' so it's working properly.

CREATED column type: DateTime

I want to cast this formate because I have got this formate on the front side.

Query:

DROP TEMPORARY TABLE IF EXISTS TEMPDATA;
CREATE TEMPORARY TABLE IF NOT EXISTS TEMPDATA AS (
SELECT DISTINCT S.ID `ID`,S.name name FROM Student S
WHERE  ( CAST(S.CREATED AS DATE) BETWEEN CAST('2021-11-30T18:30:00Z' AS DATE) AND CAST('2021-12-31T18:29:59Z' AS DATE) )
ORDER BY  name
asc limit 0,50)

Without Temprory table Query: Work Perfect

SELECT DISTINCT S.ID `ID`,S.name name FROM Student S
    WHERE  ( CAST(S.CREATED AS DATE) BETWEEN CAST('2021-11-30T18:30:00Z' AS DATE) AND CAST('2021-12-31T18:29:59Z' AS DATE) )
    ORDER BY  name
    asc limit 0,50
0 Answers
Related