Why does "my date" work and not just date when creating a Calendar entry?

It was suggested on one of the sites I visited to add “my” in front of “date” (for the life of me I can’t remember why) to overcome my Calendar date problem (see below).

My script now works but I don’t know why.

– Works
tell application “Calendar”
set theDateStr to “10/01/26”
set theDate to my date (theDateStr)
return result
end tell

– Fails
error “Calendar got an error: Can’t get date "10/01/26".” number -1728 from date “Thursday, October 1, 2026 at 12:00:00 AM”
tell application “Calendar”
set theDateStr to “10/01/26”
set theDate to date (theDateStr)
return result
end tell

Welcome to the forum, @jazzfess

Calendar.app has its own class date which cannot be used in the same way as date in Scripting Additions.

The application tell block prioritizes the application terminology, but the keyword my tells the compiler to talk to date of AppleScript itself (the date class in Scripting Additions).

Just delete the application tell block, it’s pointless in this case

set theDateStr to "10/01/26"
return date (theDateStr)
1 Like

I’m afraid the application tell block is not “pointless” since my script is Calendar based - I just provided a snippet.

Thanks.

It’s a good habit to put only those lines into an application tell block which talk to the application.
This avoids the kind of unexpected behavior you’ve run into.

And if it’s not pleasant to move commands outside the application tell block, you can clarify who they belong to with a “my”.

tell application "Calendar"
	set theDateStr to "10/01/26"
	set theDate to my date (theDateStr)
	return result
end tell
1 Like