Jump to content

Edreyn

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Edreyn

  1. As I say, I am trying to do something similar to browser games. The player starts a task, for example "forge a sword". When he starts, current time should be stored. The task also has a duration, that can change depending on other variables. I need to calculate end time myself (start + duration), then check once in a while if new current time is past end time. If it is, the task is marked as finished. So, I don't insert end time myself, I need to calculate it.
  2. Yes, that allowed me to add values of two columns, but I still don't get the expected result. INSERT INTO Processes(Name, StartTime, DurationTime, EndTime, IsFinished) SELECT 'AAA', st, dt, st + dt, 0 FROM (SELECT '2018-01-22 09:00:00' as st, '0000-00-00 00:05:00' as dt) Processes; The expected result for EndTime column is: '2018-01-22 09:05:00' The actual result is: '2018' Of course I declared EndTime as TIMESTAMP
  3. I don't have an insert for my situation, I don't even know how it could look. I'll check the link, thank you! Sorry, I didn't read correctly. I imagine something like this: INSERT INTO Processes (StartTime, DurationTime, IsFinished) VALUES ('2018-01-22 15:31:00', '0000-00-00 00:05:00', '0'); And then i want to calculate EndTime = StartTime + DurationTime
  4. Hello, I am trying to do something similar to what is used in browser MMOs. CREATE TABLE Processes ( Name varchar(255) NOT NULL UNIQUE, StartTime TIMESTAMP, DurationTime TIMESTAMP, EndTime TIMESTAMP, CurrentTime TIMESTAMP, IsFinished int, PRIMARY KEY (Name) ); Specifically: I have a process, that has a StartTime and DurationTime. IsFinished starts as 0. I need: 1) When I do INSERT: Calculate the end time, the result is put into EndTime field 2) When I want to update (for now manually, not with timer): Compare CurrentTime (should be taken automatically) to EndTime. If CurrentTime is past, IsFinished turns to '1' How it can be achieved? I have some basic knowledge, but not how to add or compare timestamps. Thank you in advance, Evgenie
×
×
  • Create New...