Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date functions
#20
(03-05-2024, 11:13 PM)Kernelpanic Wrote:
Quote:@mdijkens - You can do these and other date/time related things very easy with the library I posted above.
Just add to your program and calculate differences, leapyear, weekdays, daylight saving, timezones, etc.
Thank you for your hint. The key point about "DateDiff" is, how should I use that for calculations?
I know "DateDiff" from VB-Script and from Visual Basic, and there I used it for calculations in financial programs. I was able to use the result of “DateDiff” when calculating the repayment amount of loans.

Back then, I recalculated all formulas and results in all programs using a calculator, and when "DateDiff" was used, for example, it always delivered a correct result.

There can't be even the slightest mistake in finance. . . otherwise the Third World War will break out.  Tongue
To calculate date differences, you could easily do:

Code: (Select All)
 Dim As _Unsigned _Integer64 date1, date2

date1 = TIM.stamps("1917-09-24 15:52:31") 'seconds since 01-01-0001
date2 = TIM.stamp(2021, 2, 17, 10, 24, 49) 'alternative method

Print TIM.format$(date1)
Print TIM.format$(date2)
Print "Difference is"; date2 - date1; "seconds or"; (date2 - date1) / 86400; "days"

x$ = TIM.dateTime$(date2 - date1, year%, month%, day%, hour%, minute%, seconds%) ' fills vars & returns datetime without -/:
Print "Or"; year%; "years"; month%; "months"; day%; "days"; hour%; "hours"; minute%; "minutes and"; seconds%; "seconds"
End
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


Messages In This Thread
Date functions - by dritter - 03-04-2024, 05:49 AM
RE: Date functions - by Pete - 03-04-2024, 06:43 AM
RE: Date functions - by Dimster - 03-04-2024, 03:04 PM
RE: Date functions - by mdijkens - 03-04-2024, 04:00 PM
RE: Date functions - by Dimster - 03-04-2024, 04:43 PM
RE: Date functions - by SMcNeill - 03-04-2024, 05:51 PM
RE: Date functions - by Kernelpanic - 03-04-2024, 06:12 PM
RE: Date functions - by mdijkens - 03-04-2024, 06:46 PM
RE: Date functions - by madscijr - 03-05-2024, 07:18 PM
RE: Date functions - by Kernelpanic - 03-05-2024, 10:52 PM
RE: Date functions - by madscijr - 03-05-2024, 11:15 PM
RE: Date functions - by bplus - 03-04-2024, 06:16 PM
RE: Date functions - by Kernelpanic - 03-04-2024, 06:19 PM
RE: Date functions - by Pete - 03-04-2024, 06:43 PM
RE: Date functions - by Kernelpanic - 03-05-2024, 11:13 PM
RE: Date functions - by madscijr - 03-05-2024, 11:28 PM
RE: Date functions - by mdijkens - 03-06-2024, 07:47 AM
RE: Date functions - by Kernelpanic - 03-05-2024, 11:27 PM
RE: Date functions - by Kernelpanic - 03-05-2024, 11:48 PM
RE: Date functions - by SMcNeill - 03-06-2024, 12:23 AM
RE: Date functions - by SpriggsySpriggs - 03-06-2024, 12:24 PM
RE: Date functions - by Kernelpanic - 03-07-2024, 11:17 PM
RE: Date functions - by mdijkens - 03-08-2024, 08:03 AM
RE: Date functions - by SMcNeill - 03-07-2024, 11:29 PM
RE: Date functions - by Kernelpanic - 03-07-2024, 11:41 PM
RE: Date functions - by SpriggsySpriggs - 03-08-2024, 12:48 PM
RE: Date functions - by Kernelpanic - 03-08-2024, 03:20 PM
RE: Date functions - by mdijkens - 03-08-2024, 04:06 PM
RE: Date functions - by bplus - 03-08-2024, 04:48 PM
RE: Date functions - by mdijkens - 03-08-2024, 05:01 PM
RE: Date functions - by Kernelpanic - 03-08-2024, 09:30 PM
RE: Date functions - by dano - 05-20-2024, 04:22 PM



Users browsing this thread: 1 Guest(s)