I've been able to successfully create a keyboard shortcut from a "quick action" in Automator based on running AppleScript (inserts current system date). However, I cannot get a similar script to work for inserting tomorrow's date (current date + 1 day) or the day after (current date + 2 days).

Here's what I have:

on run {input, parameters}

    set thedate to (current date) as string
    set myNewDate to thedate + (1 * days)
    tell application "System Events"
        keystroke myNewDate
    end tell
end run

It produces this Syntax Error:

Can’t make "Tuesday, March 5, 2019 at 10:13:55 AM" into type number.

Can someone help me identify my error and fix it? Apple support won't help with AppleScript-related issues for non-developers.

Any help is greatly appreciated by this novice coder.

Thank you to Allan, Ɱark Ƭ, Wowfunhappy and others for the quick help (not just a fix, but defining my syntax issue). I have a modification: how do I tell the string to leave off the time stamp at the end: "at 12:24:21 AM" ?

  • 2
    Right off the bat...you're attempting to add an integer to something you defined as a string.
    – Allan
    Commented Mar 5, 2019 at 15:29
  • 2
    @JustinS, Please do not add additional questions after the original has been answered. One question per question. Create a new question for "how do I tell the string to leave off the time stamp at the end: "at 12:24:21 AM" ?" Commented Mar 7, 2019 at 5:53
  • Nonetheless let me add... please take the time to read thoroughly the Class Reference section for the date object in the AppleScript Language Guide as it will give you insight with how you can retrieve just the parts of what's returned by the current date command, e.g.: set thedate to date string of ((current date) + (1 * days)) as string Commented Mar 8, 2019 at 16:09

1 Answer 1


You are trying to add the day in the wrong spot. Try this:

set thedate to ((current date) + (days * 1)) as string
tell application "System Events"
    keystroke thedate
end tell

The "current date" returns the time in seconds, so you have to add one day worth of seconds (86,400 seconds in a day, but I'm sure you knew that) to get tomorrow. Change the multiplier to get more days in the future or past by using a negative value for the multiplier.

Note that not all days have 86400 seconds (DST change is +/- 3600, Leap seconds, etc…) so on some days it may be an hour off.

  • I might add... it's not that you can't add to the date later, but it has to be done before the date is turned into a string. Once the date is a string, you can't perform arithmetic on it. "My dog is fluffy." + 1 doesn't equal anything, and so neither does "Tuesday, March 5, 2019 at 10:33:22 AM" + 1 Commented Mar 5, 2019 at 16:01
  • This also works: set thedate to (current date) + (1 * days) as string Commented Mar 5, 2019 at 16:04
  • 1
    @user3439894: There is always more than one way to do something. In this case using a system provided constant is better than using a "magic number". I have updated my answer to reflect that.
    – Ɱark Ƭ
    Commented Mar 5, 2019 at 16:51
  • Thank you all so much for the prompt help. I have lots to learn and am excited to do it! What about a way to tell the (current date) to leave off the time stamp part of the string: "at 12:24:21 AM" ?
    – JustinS
    Commented Mar 7, 2019 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .