0

I have mysql datatype as date, my date format in database is 20/1/2015. Now I wish to retrieve data using date.

For example:

SELECT * FROM Device_Count where Date='20/1/2015' 
GO

I am getting error like: Incorrect date value: '20/1/2015' for column 'Date' at row 1

Please find and post the status

3 Answers 3

6

MySQL's date format is yyyy-mm-dd

change your query as below and it should work, provided your Date column data type is date.

SELECT * FROM Device_Count where Date=STR_TO_DATE('20/1/2015', '%d/%m/%Y' )

Refer to Documentation: STR_TO_DATE(str,format)

Sign up to request clarification or add additional context in comments.

Comments

0

Check your date format and compare it by the same format

Comments

0

Date is stored in MYSQL in the format of YYYY-mm-dd. Try this query:

SELECT * FROM Device_Count where Date='2015-01-20'
GO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.