Forum > Databases

Tsqlitedataset and time format as hh:mm:ss

(1/2) > >>

Sainty:
Hello all,

1. I'm inserting data to field StartTime (defined in table 'calls' as Time type):
...
SqliteDataSet.FieldByName('StartTime').AsDateTime   := StrToTime('18:59:59');
....
after all, using 'SELECT StartTime from calls' I get in my dbGrid time in hh:mm format (without seconds). How I can get it displayed with seconds?

2.  How to search database using time type? (SELECT)

Kind regards,

Sainty

JanH:
Hi Sainty,

1. In TDBGrid each column has a property named DisplayFormat. Use 'hh:mm:ss' to display hour:minute:second. Either you set this property value at design time, or you dynamically set it at runtime.

2. Try statements like this:
 
--- Code: ---SELECT * FROM calls WHERE starttime='10:11:12'
SELECT * FROM calls WHERE starttime>='10:11' and starttime<='10:12'
 
--- End code ---


Greets,

Jan

Marc:
or better (if the db supports it)
--- Code: ---SELECT * FROM calls WHERE starttime BETWEEN '10:11:00' and '10:12:00'
--- End code ---

Anonymous:

--- Quote from: "Marc" ---or better (if the db supports it)
--- Code: ---SELECT * FROM calls WHERE starttime BETWEEN '10:11:00' and '10:12:00'
--- End code ---

--- End quote ---


This wont work.
TSqliteDataset stores TDateTime as a float value.

Marc:
thats why I wrote:
--- Quote ---(if the db supports it)
--- End quote ---
:-)
It is more a generic remark that when a db supports it it is better to use
  b BETWEEN a and c
than
  (a < b) and (b < c)

since the first can be done with a sinlge index lookup.

Navigation

[0] Message Index

[#] Next page

Go to full version