Jump to content

  •  

Photo

Help with gettimestr and datetime (SQL).


  • Please log in to reply
1 reply to this topic

#1 irugationz

irugationz

    Newbie

  • Members
  • Pip
  • 8 posts
  • Github:Irugationz

Posted 31 March 2016 - 01:06 PM

I have a table in SQL which stores the datetime when the player did something (datetime format: YYYY-MM-DD HH:MM:SS).

 

I want to make a check up when the player try to talk to the NPC, that he will only proceed if the delay between the stored datetime in SQL and the current time in-game is less or equal to 25 hours.

So, if the current time is more then 25 hours later from the stored value in the SQL (datetime), the NPC won't talk.

 

But i do not know how to make those checks. How can i compare a datetime value in SQL to the current time in server plus some hours/days?

Thanks!



#2 Cretino

Cretino

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts

Posted 02 April 2016 - 01:28 PM

Try this example:

query_sql "SELECT TIMESTAMPDIFF(HOUR, `lastlogin`, NOW()) FROM `login` WHERE `account_id` = '2000000'", .@hour_diff;
mes "Diff: " + .@hour_diff;





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users


This topic has been visited by 18 user(s)