Days between two dates

Post your Gambas programming questions here.
Post Reply
User avatar
sarpomira
Posts: 20
Joined: Monday 28th December 2020 4:15pm

Days between two dates

Post by sarpomira »

Hello,

I'm trying to determine the "date difference" in days between the current day and a future date selected in a Gambas "DateBox" control.
Can anyone offer the proper syntax for comparing / subtracting two dates?

Thanks kindly in advance
User avatar
BruceSteers
Posts: 1578
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Days between two dates

Post by BruceSteers »

DateDiff
https://gambaswiki.org/wiki/lang/datediff


Dim SomeDate As Date
SomeDate = GetFutureDate()

Print DateDiff(Now, SomeDate, gb.Day)

If at first you don't succeed , try doing something differently.
BruceS
vuott
Posts: 263
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Days between two dates

Post by vuott »

sarpomira wrote: Wednesday 29th November 2023 8:32pm ...... date selected in a Gambas "DateBox" control.
In this case you need two DateBoxes.
Specifically you need to use their ".Value" Property, perhaps setting the date manually.
Public Sub Button1_Click()
 
 Print DateBox2.Value - DateBox1.Value
 
End
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
User avatar
sarpomira
Posts: 20
Joined: Monday 28th December 2020 4:15pm

Re: Days between two dates

Post by sarpomira »

Bruce and Vuott,

Thanks ! :-)
Post Reply