time, date calculation

Hello,

Is there a time calculation function build in Xojo, so I could use it to calculate time difference from MySQL date time function.
For example I got 2016-10-05 15:10:38 from MySQL I would like to check weather the time that has passed is more or less than 5 minutes and that date is current.

I had to look this up recently. See here in the documentation. I think that the dateinterval function will work for you.

you can do a sqlselect that gives you directly the correct answer

select datetime-now() from mytable

If you want to do this in the SQL SELECT statement, then the functions available are within mySQL … NOT Xojo
If you want to do this once you have the data in an Xojo Recordset, then look at the Data functions in the Xojo Lang Ref

I try to use xojo.core.date function to make calculation with following code, but it doesn’t work correctly

[code]Using Xojo.Core
Dim d As Date = Date.FromText(MysqlDate)

Dim di As New DateInterval
di.Seconds = 300 ’ 300 s

Dim d2 As Date = d + di

Dim d3 As Date = d - di

if d < d2 and d > d3 then
msgbox “time is betveen ± 300s”
end if[/code]

might be helpful to provide the value in “MySQLDate” and the results that were produced

2016-10-07 05:04:30 is MysqlDate

I have aslo try

if d.SecondsFrom1970 < d2.SecondsFrom1970 and d.SecondsFrom1970 > d3.SecondsFrom1970 then // instead of if d < d2 and d > d3 then

But still same problem.

Actually this code works OK.

2016-10-07 05:04:30 is MysqlDate

[code]Using Xojo.Core
Dim d As Date = Date.FromText(MysqlDate)
Dim dnow As Date = Date.Now

Dim di As New DateInterval
di.Seconds = 300 ’ 300 s

Dim d2 As Date = dnow + di

Dim d3 As Date = dnow - di

if d.SecondsFrom1970 < d2.SecondsFrom1970 and d.SecondsFrom1970 > d3.SecondsFrom1970 then
msgbox “time is betveen ± 300s”
end if[/code]

It was my typo in code.