SA-MP Forums Archive
timestamp mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: timestamp mysql (/showthread.php?tid=617084)



timestamp mysql - aoEXE - 15.09.2016

My question is the following

If I have a timestamp field in mysql and the date is saved in this way:

Код:
eg
'2016-09-15 08:36:21'
year-month-day hour:minute:second
How I can select the registers that for example are inactive for 1 year, or 1 month but just only mysql code?

I think that to do is comparing Unix time but I'm not quite clear how do it without use pawn code.


Re: timestamp mysql - Shinja - 15.09.2016

PHP код:
new date[11], time[11], yearmonthdayhourminutesecond;
sscanf("2016-09-15 08:36:21""s[11]s[11]"datetime);
sscanf(date"p<->ddd"yearmonthday);
sscanf(time"p<:>ddd"hourminutesecond); 
Now you have everything you need to compare


Respuesta: Re: timestamp mysql - aoEXE - 15.09.2016

Quote:
Originally Posted by Shinja
Посмотреть сообщение
PHP код:
new date[11], time[11], yearmonthdayhourminutesecond;
sscanf("2016-09-15 08:36:21""s[11]s[11]",datetime);
sscanf(date"p<->ddd"yearmonthday);
sscanf(time"p<:>ddd"hourminutesecond); 
I know do that, I wanted to know if it could be done only with MySQL code.

Something like:

'where date < olddate'

?

It is to select many registers at once.


Re: timestamp mysql - Shinja - 15.09.2016

Then you need to save each info in a column

Код:
Year     Month      Day
2016     09         15



Respuesta: timestamp mysql - aoEXE - 15.09.2016

really?


Re: timestamp mysql - Konstantinos - 15.09.2016

An example of selecting all the players (their name only) that are inactive for 1 or more years:
pawn Код:
SELECT name FROM players WHERE TIMESTAMPDIFF(YEAR, last_login, NOW()) >= 1;