아 이미지 왜 자꾸 깨짐.

이미지 자꾸 깨지니까 그냥 말로하겠음 ...딱히 할말이없네요 이미지올리고싶은데
ps&cube
접속 : 6232   Lv. 86

Category

Profile

Counter

  • 오늘 : 13 명
  • 전체 : 446837 명
  • Mypi Ver. 0.3.1 β
[학생] mysql date 사용 해보신분 계신가요..??? (3) 2017/01/27 PM 12:43

mysql command line client에서 테스트는 이미 완료했는데요...

 select id,name,modelnumber,series,content,date_format(writedate,'%y-%m')from products;


이쿼리가 잘실행됩니다.


node.js로 하고있는데요

로직부분 js파일에서

client.query("select id,name,modelnumber,series,content,date_format(writedate,"+'%y-%M'+")from products",function(error,results){

이안에서 res.render로 페이지로 select 쿼리 결과 results를 전달해줍니다.

여기서 date_format써서 년-월 이런식으로 표시하고 싶은데 ' 처리를어떻게 해야할지모르겠습니다.]


errorError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%y-%M)from products' at line 1
이런식으로 에러가납니다.

date_format(writedate,'%y-%M')
이렇게하면 writedate 데이터가 아예안나오고...

date_format(writedate, %y-%M)
하면 똑같은에러나오고...

조언좀주세요 ㅜㅠ

아. 또하나. %M하면 영어로 달이 January이렇게 나오고 %m이러면 01로나오는데요, 혹시 한글로 나오게 하거나 하는 방법이 따로있을까요?  


신고

 

ps&cube    친구신청

insert 할때 now()통해서했습니다.

컹컹컹컹컹컹컹    친구신청

쿼리문 적으신 부분에
+'"%y-%M"'+ 식으로 따옴표를 정리해서 넣으셔야 할듯요

%m 에 한글은 mysql 에선 처리 안해주니까 데이타를 받아서 직접 가공하시면 됩니다

ps&cube    친구신청

"select id,name,modelnumber,series,content,date_format(writedate,"+'"%y--%M"'+")from products" 해도안되네요 ㅜ
X