Tell aDate to set {its month, its day, its year} to {6,1,2000} -> JULY 1, 2000?

When I run this script for this particular date on my M1Mac Mini 11.2.3, the aDate’s month is July. On my MacBook Pro (15-inch, 2018) 11.2.3 it is June. Am I doing something obviously wrong?

set theDate to current date
set theYear to 2000
set theMonth to 6
set theDay to 1
tell theDate to set {its month, its day, its year, its hours, its minutes, its seconds} to {theMonth, theDay, theYear, 0, 0, 0}
display dialog theDate as text
-->Saturday, July 1, 2000 at 00:00:00

I’m guessing you ran it on March 31. So when the month was changed to June, which only has 30 days, day 31 of month 6, which doesn’t exist, became day 1 of month 7.

The solution is to make sure you set the day to 28 or earlier before setting the month:

set theDate to current date
set theYear to 2000
set theMonth to 6
set theDay to 1
tell theDate to set {its day, its month, its day, its year, its hours, its minutes, its seconds} to {1, theMonth, theDay, theYear, 0, 0, 0}
display dialog theDate as text

Exactly. If I would have only struggled on.
Now I remember reading this same discusion with the caveat to do the ‘double day set’ some years ago. Consequent lazy typing and it “workiing” led me to losing June.
Funny that on the PowerBook it didn’t work and the M1 Mini it worked. :smirk:
Maybe now I will remember.
Thanks.