[HELP] mysql date column [REP+]
#1

Hello I have in LastActivity column is set to timestamp and it saves on disconnect in format like 2014-07-20 18:12:33

so I want there only date and in format 20/07/2014 is this possible to make I try everything but it won't work. Thanks
Reply
#2

PHP код:
SELECT DATE(LastActivity) AS LastActivity FROM table WHERE ... 
Very easy.
Reply
#3

is this fine? I mean is it work

pawn Код:
mysql_format(mysql,query,sizeof(query),"select date_format(LastActivity,'%%e/%%c/%%Y') FROM `users` WHERE `ID` = '%d'",PlayerInfo[playerid][ID]);
        mysql_tquery(mysql,query,"","");
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
PHP код:
SELECT DATE(LastActivity) AS LastActivity FROM table WHERE ... 
Very easy.
I will try it then

I'm sorry instead of edit existing post I make the new one sorry for dp(double post)

edit: I try and in the column still stays 2014-07-20 19:47:10

also I was try like this

pawn Код:
mysql_format(mysql,query,sizeof(query),"SELECT DATE_FORMAT(LastActivity,'%e/%c/%Y') FROM `users` WHERE `ID` = '%d'",PlayerInfo[playerid][ID]);
        mysql_tquery(mysql,query,"","");
and I get this in mysql_log

20:12:34 mysql_format ERROR no value for specifier "%c" available
20:12:34 mysql_format ERROR no value for specifier "%Y" available
Reply
#5

anyone? thanks
Reply
#6

Ok, the problem is that you have to escape the '%' symbol. For that, put a \%

mysql_format(mysql,query,sizeof(query),"SELECT DATE_FORMAT(LastActivity,'\%e/\%c/\%Y') FROM `users` WHERE `ID` = '%d'",PlayerInfo[playerid][ID]);
mysql_tquery(mysql,query,"","");
Reply
#7

problem still remains it says

mysql_format ERROR no value for specifier "%c" available
mysql_format ERROR no value for specifier "%Y" available

Thanks.
Reply
#8

anyone? thanks
Reply
#9

anyone? thanks
Reply
#10

anyone? thanks
Reply
#11

Perhaps try only bumping your post once, as the rules state?

On topic: try just using %d as it's numerical. I may be wrong, I haven't used timestamps much with MySQL
Reply
#12

anyone? thanks
Reply
#13

I see why you've got -7 rep.
Reply
#14

anyone' ? thanks
Reply
#15

anyone? thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)