k.horde k.horde - 6 months ago 20
SQL Question

SQL how to pull out data which has commas without them?

In the database there is date put into fields with commas like

which stands for date

I need to take out the date and filter it so that I have only records from a period of time.

Do you know how I can pull out the data without the commas so I have integers which I can compare then?


Remove the commas using REPLACE, and then convert to a date using TIMESTAMP_FORMAT and DATE:



SELECT DATE(TIMESTAMP_FORMAT(REPLACE('20,151,112', ',', ''), 'YYYYMMDD')) AS "theDate"
FROM yourTable