Lazarus

Programming => Packages and Libraries => LazReport => Topic started by: SteenJorgensen on September 10, 2019, 11:31:13 am

Title: Need a Minutesbetween(dt, dt) i the scripts
Post by: SteenJorgensen on September 10, 2019, 11:31:13 am
I can't find document about adding a function and have try alot without luck.

How can i implement a minutesbetween functions?

Thanks...
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: howardpc on September 10, 2019, 12:54:26 pm
This functionality is already  available, you don't need to reinvent the wheel.
Code: Pascal  [Select][+][-]
  1. uses DateUtils;
  2.  
  3. Function MinutesBetween(const ANow, AThen: TDateTime): Int64;
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: rvk on September 10, 2019, 12:55:52 pm
This functionality is already  available, you don't need to reinvent the wheel.
Yes, I also already posted that answer but removed it because TS is asking this for in a script in LazReport.

So how do you use this in LazReport (of which I have no knowledge)?
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: SteenJorgensen on September 10, 2019, 01:11:01 pm
Thanks for answer.

I know the function i dateutils, but i need it in a script in lazreport. See attach file.
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: Zvoni on September 10, 2019, 02:25:13 pm
Why not create a View in your DB, where you calculate the "MinutesBetween" in your SQLQuery?
Then it would be just a DB-Field like any other....
On the other Hand: a TDateTime is just an Alias for a Double.
If you remember, that a Day has 1,440 Minutes, it should be actually pretty easy to calculate it by yourself, if there is no Function available
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: SteenJorgensen on September 13, 2019, 10:41:17 am
A view in DB with specific result is not an options for me. The app let the user to create there own reports.
And Datetime is correct a double in Lazarus IDE but not in handling a report.
Title: Re: Need a Minutesbetween(dt, dt) i the scripts
Post by: Zvoni on September 13, 2019, 12:34:16 pm
So whats the DB-Format of those two dates you're grabbing from the DB?
Built-In DateTime, Some Text, Reversed Integer-Notation?
Say, in SQLite, Dates are some weird text-Format, in MySQL it's basically a Double again etc...
TinyPortal © 2005-2018