DavJans wrote:Currently I have a datagrid that shows me date/time/item/location. Each line item is added by a worker for inspection, is there a way to add another column that counts up the seconds/minutes/days that it has been on the list? The date and time I get using "put short date into var" and "put short time into var2" before adding the entry into MySQL database.
secondary question is I haven't figured out how to format date and time to use MySQL date and time specific columns.
I'm not sure to understand.
1- do add date or time or timestamp values in a MySQL database... there is an easier way : ask the MySQL server to do the work.
for instance :
Code: Select all
update mytable set mydate=CURRENT_DATE where myrecord=1
insert into mytable (mydate) VALUES (CURRENT_TIMESTAMP)
2-it seems you want to know "how long" a line was created/added in your datagrid, right ? In this case, when you create the row, in one column ("start") :
And then, when you "finish", put the seconds again
After that, you just have to subtract "start" from "finish"... you get the duration in seconds, a value you can easily convert after in minutes, hours, whatever.
3-last but not least... again you could ask MySQL do this work itself.
for instance :
(provided start_time is a timestamp column)
Code: Select all
update mytable set total_duration=CURRENT_TIMESTAMP-start_time where myrecord=1
4-to display a date DAY / MONTH / YEAR
Code: Select all
select date_format(mydate,'%d/%m/%y') from mytable where myrecord=1
Google MySQL date time... you'll find plenty of informations.