Insert Date inside mysql column
#1

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);
Reply
#2

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(mysqlquerysizeof(query),"INSERT INTO `bugs` (`BugReporter`,`BugInfo`,`Date`) VALUES ('%s','%s', NOW())",BugReporter,BugInfo); 
Reply
#3

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(mysqlquerysizeof(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 ?
Reply
#4

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.
Reply
#5

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
Reply
#6

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.
Reply
#7

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"
Reply
#8

Код:
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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)