Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Current_Date()-s.mydate problem
Thu, Jan 31 2019 4:22 PMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

If I run a

>>  select (current_date()-s.lagerdatum) lagertage from mytable

from Db-Manager i get days as a result.

If i run same sql within a tedbquery i get another value, i think seconds.
Is there a setting i'm missing?

But:
>>  select cast(current_date()-s.lagerdatum as integer) lagertage from mytable

i get the correct days from both apps.

Yusuf Zorlu
MicrotronX
Thu, Jan 31 2019 5:56 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Yusuf ,

What is the type of "s.lagerdatum" ?

--
Fernando Dias
[Team Elevate]
Fri, Feb 1 2019 12:30 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Fernando Dias wrote:
>> What is the type of "s.lagerdatum" ?

It is defined as "LAGERDATUM" DATE

Yusuf Zorlu
MicrotronX
Fri, Feb 1 2019 2:20 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf


I've just tried in EDBManager 2.30b2 and I get the correct result each time.


Roy Lambert
Fri, Feb 1 2019 3:18 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Roy Lambert wrote:

>> I've just tried in EDBManager 2.30b2 and I get the correct result each time.

Yes Roy, that is correct, but if you do the same with a tedbquery component from delphi (in my case) i get false result! from edbmanager it works, from my tedbquery with latest 2.30b2 it does show it in seconds or minutes...

Yusuf Zorlu
MicrotronX
Fri, Feb 1 2019 3:48 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf


Remember EDBManager is just another Delphi application. There must be something different you, or your application, are doing to get a different result.

Roy Lambert
Fri, Feb 1 2019 3:51 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Roy Lambert wrote:

>> Remember EDBManager is just another Delphi application. There must be something different you, or your application, are doing to get a different result.

And I'm searching for that but i don't know where the setting is, which defines how the query results days or seconds for that query ...

I can run the same query, in EDBManager and in my simple delphi app and both show different values for same sql, one shows days one seconds ... Is this a setting somewhere in edbsession?

At the moment i have changed all sourcecode sql scripts to use cast(current_date()-s.lagerdatum as integer), this works in both cases

Yusuf Zorlu
MicrotronX
Fri, Feb 1 2019 4:39 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Yusuf


That has triggered a buried memory (I think but it may be a fake one). Tim may have altered the resultset grid in EDBManager to show days rather than milliseconds in the same way that it displays "NULL" rather than an empty cell.

My brain says there was a post about this but I can't come up with the right search to find it.

I've just tried in 2.28b7 which is what I have installed and I get ms rather than days


Roy Lambert
Fri, Feb 1 2019 1:52 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yusuf,

<< If i run same sql within a tedbquery i get another value, i think seconds. >>

The value that you're seeing is the "raw" value for a day-time interval, which happens to be the number of milliseconds between the two dates.

You can see how this is handled in the EDB Manager in the main.pas unit for the edbmgr.dpr project included with the utilities, but here it is so you don't have to go dig it up:

procedure TMainForm.GetDayTimeIntervalText(Sender: TField; var Text: String;
                                          DisplayText: Boolean);
begin
  if DisplayText and Sender.IsNull then
     Text:='NULL'
  else
     begin
     if Sender.IsNull then
        Text:=''
     else
        Text:=Engine.DayTimeIntervalToSQLStr(TLargeIntField(Sender).AsLargeInt,
             TEDBDataSet(Sender.DataSet).GetDayTimeIntervalTypeForField(Sender.FieldName));
     end;
end;

procedure TMainForm.SetDayTimeIntervalText(Sender: TField; const Text: String);
begin
  if (Text <> '') then
     TLargeIntField(Sender).AsLargeInt:=Engine.SQLStrToDayTimeInterval(Text,
        TEDBDataSet(Sender.DataSet).GetDayTimeIntervalTypeForField(Sender.FieldName))
  else
     Sender.Clear;
end;

This is for the OnGetText/OnSetText event handlers for the TFields, which the EDB Manager hooks up automatically/dynamically for every dataset.

If you don't need the user to be able to edit the result set, then you can also just use a CAST call in your query to cast the SELECT expression to a VARCHAR so that it will automatically be the correct display value.

All of this is due to the fact that Delphi doesn't have date/time interval field types, so EDB has to map them to their underlying raw types (32-bit integers for year-month intervals, and 64-bit integers for day-time intervals).

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 4 2019 12:54 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Tim Young [Elevate Software] wrote:

<< If you don't need the user to be able to edit the result set, then you can also just use a CAST call in your query to cast the SELECT expression to a VARCHAR so that it will automatically be the correct display value.


Hi Tim, is it correct that my use of CAST AS INTEGER results in correct DAY values?

Yusuf Zorlu
MicrotronX
Page 1 of 2Next Page »
Jump to Page:  1 2
Image