Sorry, I'm very new to DbGrids.
Should I use the query field editor and somehow add a new field that captures TIMEDIFF and then just add this as a column in my DbGrid?
Or can / should I skip the field editor and somehow declare TIMEDIFFF as a column?
For this table, I want a DbGrid with 4 columns: start time, end time, duration, description (run_id is the primary key and will not be displayed).
I am focused on how to get the data in the "duration" column ...
mysql> describe test_runs; +------------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+-------------+------+-----+---------+----------------+ | run_id | int(11) | NO | PRI | NULL | auto_increment | | start_time_stamp | timestamp | YES | | NULL | | | end_time_stamp | timestamp | YES | | NULL | | | description | varchar(64) | YES | | NULL | | +------------------+-------------+------+-----+---------+----------------+ 4 rows in set (0.37 sec)
[Update] Query for data source
SELECT start_time_stamp, end_time_stamp, TIMEDIFF(end_time_stamp, start_time_stamp) as duration, description FROM test_runs ORDER BY start_time_stamp DESC
and when I run it manually in MySql, I get
mysql> select TIMEDIFF(end_time_stamp, start_time_stamp) as duration FROM +----------+ | duration | +----------+ | NULL | | 00:04:43 | | 00:00:13 | | 00:00:06 | | 00:00:04 | +----------+ 5 rows in set (0.00 sec)
but the corresponding column in the database grid remains empty. Can anyone help? Thanks.
[Update] I am using AnyDac if this helps. The query creates all the fields, including the time difference, in MySql, as well as in the Delphi environment, when I use the AnYDac query editor and execute it.
The only problem is that I do not see it in the DB grid at runtime. I double click on the DB tree at design time and the columns are correct. The FielName FielName set to duration , which is reconfigured by the query shown above. It does not exist in the database, but is calculated on request; can this somehow be a problem?
[Aaaaaaaargh !!!] Someone tried to "improve" my code and programmatically program the query text at runtime (like SELECT * FROM test_runs) , thereby overwriting my design time query !! Since the databse table has no duration , none were shown in the database table.
There were words, the voices were dirty, and now I have to refuse, spending your time. Unfortunately.