Using dates | MySQL with Pawn
#1

Hello everyone.
I want a function like gettime and getdate of pawn, but using a value of a MySQL field, but I have no idea how to do this.
I use BlueG plugin and I did a test:
pawn Код:
YCMD:test(playerid, params[], help)
{
    if(Player[playerid][Level] < 3)
        return 0;
    new Query[64];
    mysql_format(ID, Query, sizeof(Query), "SELECT Re_Date FROM Users WHERE PlayerName='Wil'");
    new Cache:result = mysql_query(ID, Query);
    ENME(playerid, -1, "%d", cache_get_field_content_int(0, "Re_Date", ID));
    cache_delete(result, ID_Conexion);
    return 1;
}
And it returned 2014, I think that it returns the year, but the content of that field has a date-time format.
So how can I create or use a function like this?
pawn Код:
cache_get_field_content_date(row, const field_name[], connectionHandle = 1, &year, &month, &day)
Or something similar
I think also that using UNIX Timestamp (or something like that), is very hard to use, because I want compare months, years, days, etc, like an integer, anyway it doesn't return UNIX Timestamp and if that could work, convert that to 6 integers I think that is a big problem :P for me...
Thanks if someone can help me
Reply
#2

If you don't want to use Unix timestamps, you can also opt to use MySQL's DATETIME type. This allows for functions such as datediff. http://dev.mysql.com/doc/refman/5.5/...functions.html
Reply
#3

Do the DATETIME in mysql format, and when loading it load it into a string and that's it!
Reply
#4

Thanks! very helpful that page
I should learn and read more about MySQL
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)