Date trigger

Is there a simple way to display a messagebox at a specific date and time?
I don’t believe the two var are comparing properly, below. Hopefully this makes sense

Using Xojo.Core
var d1 As Date = Date.Now
var d2 As New Date(2020, 8, 13, 13, 05,TimeZone.Current)

if d1 < d2 then
messagebox ("<")
messagebox (“end”)
end if

Also…I can’t get DateTime to work…can’t find type error…wondering if something else needs to be loaded???

Dim d1 As Xojo.Core.Date = Xojo.Core.Date.Now
Dim d2 As New Xojo.Core.Date(2020, 8, 9, 12, 28,0,  Xojo.Core.TimeZone.Current)

// If d1. < d2 Then (see waynes comment following this)
If d1.SecondsFrom1970 < d2.SecondsFrom1970 Then
  MsgBox ("<")
  MsgBox ("end")
End If

Your constructor is wrong and doesnt have enough params
And there is ambiguity around the types (regardless of the fact that you have a using clause since there is a global date class and one in Xojo.Core as well - be explicit and it helps)
And compare the total seconds (as Wayne suggested after my post) instead of the objects references which is what < does (unfortunately)

According the the documentation for Xojo.Core.Date you need to compare the secondsfrom1970 properties. See

DateTime was introduced in version 2019R2 and is not yet available for iOS projects.

Thanks Wayne…I saw the secondsfrom1970 option but was hoping for something a little easier, but I can work with this.

And thanks for the note about datetime not being available on IOS projects, glad to know it wasn’t me.

Thanks Norman (and Wayne) totally makes sense now but I’d still be at it (or had given up) if it wasn’t for your help. Thanks! onto the next one :smile:

Thanks again…any reason why “=” wouldn’t work? I’ve set it up on a timer to run every 1000ms but I can’t seem to get this to trigger at exactly the right time?

Because the class doesnt implement operator_compare
So = means “are they referring to the same instance” not “are their total seconds the same”

got it…makes total sense…thanks again. Will go back and watch some beginner tutorials again…thanks for your time