I am sure this has to exist and be simple and even basic (at least I would think), but I can't seem to find information anywhere. I want to use Arcade to compare two dates (without time; just month, day, year) to see if they match. The problem is that these dates I am working with have time associated with them. So they don't match because the time doesn't match. For this accomplishment, I do not care for the time, only the month, day and year part of the date in the comparison.
I'm guessing it will be a conversion of those dates to a mmddyyyy only format within a variable, but I literally cannot find anything on how to accomplish this.
Solved! Go to Solution.
You can use Text() to format:
var d1 = Today()
var d2 = Now()
// Compare directly
Console(d1)
Console(d2)
Console("Dates are equal: " + (d1 == d2))
// Remove time and compare
var d1 = Date(Text(d1, "Y-MM-DD"))
var d2 = Date(Text(d2, "Y-MM-DD"))
Console(d1)
Console(d2)
Console("Dates are equal: " + (d1 == d2))
2022-09-14T00:00:00+02:00 2022-09-14T18:04:23.078+02:00 Dates are equal: false
2022-09-14T00:00:00+02:00 2022-09-14T00:00:00+02:00 Dates are equal: true
You can use Text() to format:
var d1 = Today()
var d2 = Now()
// Compare directly
Console(d1)
Console(d2)
Console("Dates are equal: " + (d1 == d2))
// Remove time and compare
var d1 = Date(Text(d1, "Y-MM-DD"))
var d2 = Date(Text(d2, "Y-MM-DD"))
Console(d1)
Console(d2)
Console("Dates are equal: " + (d1 == d2))
2022-09-14T00:00:00+02:00 2022-09-14T18:04:23.078+02:00 Dates are equal: false
2022-09-14T00:00:00+02:00 2022-09-14T00:00:00+02:00 Dates are equal: true
Fantastic! Thank you kindly! 🙂