Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Initfind on a timestamp field (dbisam)
Thu, Nov 19 2015 8:09 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

I hope someone can spot why i cannot get a result of a search in
ewb2/dbisam.

Dataset "tider" -> points to a dbisam table containing 2 fields, timerid
(autoinc), time (timestamp)..

Sample data from table:

Timerid,Time
=========
1,00:00:00
2,00:15:00
3;00:30:00

etc..

Code in ewb:

FormatSettings.DateSeparator := '-';
FormatSettings.TimeSeparator := ':';
FormatSettings.ShortDateFormat := 'dd-MM-yyyy';
FormatSettings.ShortTimeFormat := 'HH:mm';

   with Tider do
      begin
      Columns['Timerid'].SortDirection:=sdAscending;
      SortCaseInsensitive:=True;
      SortLocaleInsensitive:=True;
      Sort;
      InitFind;
      Columns['Time'].AsTime:=strtotime(StartTidEdit.Text);
//      Columns['Time'].AsTime:=strtotime(StartTidEdit.Text + ':0');
//      Columns['Time'].AsTime:=strtotime(StartTidEdit.Text + ':00');
      if Find(False,True) then begin
         Aktuelstarttid := Columns['Timerid'].AsInteger;
         Result:=True;
      end
      else
         Result:=False;
      end;

Does initfind not work with timestamp fields or?

Thanks in advance.

Regards,
Hüseyin A.

Thu, Nov 19 2015 8:19 AMPermanent Link

Matthew Jones

Hüseyin Aliz wrote:

> Columns['Time'].AsTime:=strtotime(StartTidEdit.Text);

I don't know anything about this, but my first check would be what this
actually gives you. Does strtotime give you a small number, or the
local time which includes "today"? Not clear from the help, and I
suspect it is "2pm today" rather than a generic 2pm. You need the
latter to match your table, I think?

--

Matthew Jones
Thu, Nov 19 2015 8:26 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi Matthew,

Showmessage(StartTidEdit.Text) returns 00:30 and does not find any
records in table, but following does not work either:

//      Columns['Time'].AsTime:=strtotime(StartTidEdit.Text + ':0'); ->
returns 00:30:0
//      Columns['Time'].AsTime:=strtotime(StartTidEdit.Text + ':00'); ->
returns 00:30:00

Yes, i need to get the timerid of the table where time are selected by
user from a dropdown box. Kind of dblookupcombox function like in delphi Smile

Regards,
Hüseyin



Den 19-11-2015 kl. 14:19 skrev Matthew Jones:
> Hüseyin Aliz wrote:
>
>> Columns['Time'].AsTime:=strtotime(StartTidEdit.Text);
> I don't know anything about this, but my first check would be what this
> actually gives you. Does strtotime give you a small number, or the
> local time which includes "today"? Not clear from the help, and I
> suspect it is "2pm today" rather than a generic 2pm. You need the
> latter to match your table, I think?
>
Thu, Nov 19 2015 8:32 AMPermanent Link

Matthew Jones

Hüseyin Aliz wrote:

> Showmessage(StartTidEdit.Text) returns 00:30

It would, but that isn't what you are setting the field to. You are
setting it to strtotime('00:30'). Do a showmessage on the integer value
that this returns. If it is under 10,000 or so, I'd think it right. If
it is a few billion, then it is "today".

--

Matthew Jones
Thu, Nov 19 2015 10:33 AMPermanent Link

Raul

Team Elevate Team Elevate

On 11/19/2015 8:09 AM, Hüseyin Aliz wrote:
> Dataset "tider" -> points to a dbisam table containing 2 fields, timerid
> (autoinc), time (timestamp)..
>
> Sample data from table:
>
> Timerid,Time
> =========
> 1,00:00:00
> 2,00:15:00
> 3;00:30:00

If your field is timestamp then where is the date portion ?

"00:30:00" is not what i would call a normal timestamp field in dbisam
(looks lie time fieldtype to me).

Either way these will get translated into EWB date type which is NOT
same is dbisam - its integer from approx 1970.


>        Columns['Time'].AsTime:=strtotime(StartTidEdit.Text);

If you're just entering '00:30' then yes nothing will be found.

Just do this and see what you get back :

ShowMessage( DateTimeToStr(strtotime('00:30')));

In my case i'm seeing '31-12-1969 00:30' since EWB has to supply the
date portion.


> Does initfind not work with timestamp fields or?

Yes it does - you have to provide a properly formatted EWB datetime.

In my test table i have a time type data field which contains "00:30".
In EWB side this is represented as -2209159800000 or as UTC foramtted
string it is  "30-12-1899 00:30".


So assuming user just enters the time (i.e. '00:30') i could construct a
datetime as

StrToDateTime('30-12-1899 ' + StartTidEdit.Text,true)

and then Find should find your record just fine.


Raul
Thu, Nov 19 2015 4:32 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Raul,

You are correct, it was not timestamp but time that was the field type
(can see now i could use another name for the fieldname as it's the same
as the type) Smile

Regards,
Hüseyin

On 19-11-2015 16:33, Raul wrote:
> On 11/19/2015 8:09 AM, Hüseyin Aliz wrote:
>> Dataset "tider" -> points to a dbisam table containing 2 fields, timerid
>> (autoinc), time (timestamp)..
>>
>> Sample data from table:
>>
>> Timerid,Time
>> =========
>> 1,00:00:00
>> 2,00:15:00
>> 3;00:30:00
>
> If your field is timestamp then where is the date portion ?
>
> "00:30:00" is not what i would call a normal timestamp field in dbisam
> (looks lie time fieldtype to me).
>
> Either way these will get translated into EWB date type which is NOT
> same is dbisam - its integer from approx 1970.
>
>
>> Columns['Time'].AsTime:=strtotime(StartTidEdit.Text);
>
> If you're just entering '00:30' then yes nothing will be found.
>
> Just do this and see what you get back :
>
> ShowMessage( DateTimeToStr(strtotime('00:30')));
>
> In my case i'm seeing '31-12-1969 00:30' since EWB has to supply the
> date portion.
>
>
>> Does initfind not work with timestamp fields or?
>
> Yes it does - you have to provide a properly formatted EWB datetime.
>
> In my test table i have a time type data field which contains "00:30".
> In EWB side this is represented as -2209159800000 or as UTC foramtted
> string it is  "30-12-1899 00:30".
>
>
> So assuming user just enters the time (i.e. '00:30') i could construct
> a datetime as
>
> StrToDateTime('30-12-1899 ' + StartTidEdit.Text,true)
>
> and then Find should find your record just fine.
>
>
> Raul
Thu, Nov 19 2015 4:33 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Matthew,

See my reply to Raul, it was my mistake, the field type is time and not
timestamp.

Regards,
Hüseyin


On 19-11-2015 14:32, Matthew Jones wrote:
> Hüseyin Aliz wrote:
>
>> Showmessage(StartTidEdit.Text) returns 00:30
> It would, but that isn't what you are setting the field to. You are
> setting it to strtotime('00:30'). Do a showmessage on the integer value
> that this returns. If it is under 10,000 or so, I'd think it right. If
> it is a few billion, then it is "today".
>
Image