0

I have some problem to convert an SQL Server query into MySQL. In SQL Server, the function recognize as DATENAME() and I changed it into MONTHNAME(). Then dateadd() in SQL Server become date_add() function.

Some sample for SQL Server query is

DATENAME("month",DATEADD("month",1,'8/1/2006'))

As I mentioned above, the query works well in SQL Server but it's not working at MySQL.

Then I tried rewrite the function into like this

MONTHNAME("8/1/2006",DATE_ADD("8/1/2006", INTERVAL 1 month))

Once again, it nots working.

How to fix that?

11
  • Firstly only tag the RDBMS you want your solution in. Commented Aug 29, 2022 at 4:05
  • added it, rdbms tag Commented Aug 29, 2022 at 4:08
  • No, I meant don't tag SQL Server because you are not looking for SQL Server experts, you are looking for MySQL experts. Commented Aug 29, 2022 at 4:09
  • What does MONTHNAME("8/1/2006",DATE_ADD("8/1/2006", INTERVAL 1 month)) give you and what do you want it to return? Commented Aug 29, 2022 at 4:10
  • #1582 - Incorrect parameter count in the call to native function 'MONTHNAME' Commented Aug 29, 2022 at 4:12

1 Answer 1

1

there is easy way to solve my problem.

i just rewrite it again from

MONTHNAME("8/1/2006",DATE_ADD("8/1/2006", INTERVAL 1 month))

into this

DATE_FORMAT(DATE_ADD("8/1/2006", INTERVAL 1 month), "%M")

this way, i get what i want

NOTE: THANKS FOR THE DOCUMENT MR P.SALMON

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

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.