Insert Date inside mysql column -
CoachCarter - 07.10.2016
Hey guys haven't been here for a while. I need a little help.
I am trying to create Donate system with Join and Expire dates and that's why I created "DonatJoinDate" "DonatExpireDate" in the Account saving table, but the problem is I can't Insert dates inside them I just don't know how.
Here is mysql database photo of that variables:
I want to make "DonatExpireDate" to be 30 days from "DonatJoinDate". I think I need this type of code:
Код:
format(query,256,"UPDATE accounts SET DonatJoinDate='%e' WHERE DonatExpireDate='%s'",newpass,PlayerName(playerid));
mysql_tquery(handlesql, query);
And also how can I detect if the expire date has come during the player spawn, like if(Expiredate >= Gettime) Removedonat(playerid);
Re: Insert Date inside mysql column -
vassilis - 07.10.2016
Mysql has a function that is called NOW and prints the current time the query gets implemented.
EDIT: for example at my bug report command here, i am using this function as you can see. You can get an idea of how to save date.
PHP код:
mysql_format(mysql, query, sizeof(query),"INSERT INTO `bugs` (`BugReporter`,`BugInfo`,`Date`) VALUES ('%s','%s', NOW())",BugReporter,BugInfo);
Re: Insert Date inside mysql column -
CoachCarter - 07.10.2016
Quote:
Originally Posted by vassilis
Mysql has a function that is called NOW and prints the current time the command happens.
EDIT: for example at my bug report command here is my mysql_format
PHP код:
mysql_format(mysql, query, sizeof(query),"INSERT INTO `bugs` (`BugReporter`,`BugInfo`,`Date`) VALUES ('%s','%s', NOW())",BugReporter,BugInfo);
|
Mhm.. interesting, and how can I insert ExpireDate 30 days from "NOW"(date when that happened), is it even possible ?
Re: Insert Date inside mysql column -
vassilis - 07.10.2016
Quote:
Originally Posted by CoachCarter
Mhm.. interesting, and how can I insert ExpireDate 30 days from "NOW"(date when that happened), is it even possible ?
|
I guess a timer that could be repeated every 24hours and each repeat removes 1 day would be lit.
Re: Insert Date inside mysql column -
CoachCarter - 07.10.2016
Quote:
Originally Posted by vassilis
I guess a timer that could be repeated every 24hours and each repeat removes 1 day would be lit.
|
I am sure there's gonna be a different way
Re: Insert Date inside mysql column -
Vince - 07.10.2016
See DATE_ADD() MySQL function. You don't need a timer to expire it. Whether a person is a VIP or something can simply be determined by checking that
current date < expire date.
Re: Insert Date inside mysql column -
CoachCarter - 07.10.2016
Quote:
Originally Posted by Vince
See DATE_ADD() MySQL function. You don't need a timer to expire it. Whether a person is a VIP or something can simply be determined by checking that current date < expire date.
|
Yes yes, that is what I needed thanks, But I can't fit it to the UPDATE functions
and what's the if code for:
"current date >= expire date"
Re: Insert Date inside mysql column -
CoachCarter - 07.10.2016
Код:
format(query,256,"UPDATE accounts SET DonatJoinDate='%e' WHERE DonatExpireDate='%s'",NOW(),TIMESTAMPDIFF(DAY, NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY)));
mysql_tquery(handlesql, query);
is this the right code?