Recent

Author Topic: Need a Minutesbetween(dt, dt) i the scripts  (Read 2146 times)

SteenJorgensen

  • Jr. Member
  • **
  • Posts: 68
Need a Minutesbetween(dt, dt) i the scripts
« 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...
----------------------------------------
Lazarus version 2.0.12 64-bit
FPC 3.2.0

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #1 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;

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #2 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)?

SteenJorgensen

  • Jr. Member
  • **
  • Posts: 68
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #3 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.
« Last Edit: September 10, 2019, 01:21:30 pm by SteenJorgensen »
----------------------------------------
Lazarus version 2.0.12 64-bit
FPC 3.2.0

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #4 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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

SteenJorgensen

  • Jr. Member
  • **
  • Posts: 68
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #5 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.
----------------------------------------
Lazarus version 2.0.12 64-bit
FPC 3.2.0

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Need a Minutesbetween(dt, dt) i the scripts
« Reply #6 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...
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018