You can do it with AppleScript, invoked with a keyboard combination. I found a few datepicker scripts online. They were all basically the same script. I barely know how they work but I adapted one to insert the picked date & time into Numbers cells. The one problem I found with this datepicker is it does not highlight the chosen date when you pick it. I was unable to figure out how to change that. It will correctly return the date you clicked on but there is no visual feedback of the date you picked. You'll see what I mean when you try it out.
Any computer that will be running your Numbers document would need this quick action installed to use the date picker; it is not part of the document.
Try it out first before doing the other stuff below:
- Open Script Editor app
- Paste the code from below into a new document
- Select a cell or a range of cells in Numbers
- Back in Script Editor hit the run button
If it looks like it does what you want, continue on.
From what I can tell, this datepicker script has to be run from within the Numbers app if you want its window to be on top. So, I made a "quick action" from it that can be run from the Numbers/Services menu.
- Open the Automator app
- Create a new Quick Action
- Set the workflow to receive "no input" in "Numbers.app"
- From the Utilities folder, drag the "Run Applescript" action to the window
- Delete everything that is there and replace it with the script from below
- Save it with a name like Numbers Date Picker
In Numbers, this 'quick action" will show up in the Numbers/Services menu.
Select a cell or range of cells then run the date picker from the Services menu
If you are okay with how it works and you want to be able to invoke it with a keyboard shortcut,
- Open System Preferences/Keyboard/Shortcuts/App Shortcuts
- Hit the + and create a shortcut for Numbers
- Type in the menu item name exactly as you see it in the menu, including all caps and punctuation
- Give it a keyboard shortcut
Note: With one line change, the date picker can be shown as a scroller instead of a "calendar" where you can pick the day, month, year, etc. number by number. This solves the problem of lack of visual feedback but it is not the calendar style picker most people think of.
# 06/04/16 09:35:02
# Author: Shane Stanley
# Adapted by Christopher Stone
# Fixed & Rewritten by CJK
# Adapted for Numbers app by Badunit
--------------------------------------------------------------------------------
use framework "AppKit"
use scripting additions
property this : a reference to the current application
property nil : a reference to missing value
property _1 : a reference to reference
property NSAlert : a reference to NSAlert of this
property NSDatePicker : a reference to NSDatePicker of this
property NSView : a reference to NSView of this
property NSAlertFirstButtonReturn : 1000
property NSAlertSecondButtonReturn : 1001
property NSHourMinuteSecondDatePickerElementFlag : 14
property NSClockAndCalendarDatePickerStyle : 1
property NSYearMonthDayDatePickerElementFlag : 224
--------------------------------------------------------------------------------
property date : missing value
property returnCode : missing value
--------------------------------------------------------------------------------
on run
its performSelectorOnMainThread:("showDatePicker:") withObject:{¬
NSClockAndCalendarDatePickerStyle, ¬
NSYearMonthDayDatePickerElementFlag + ¬
NSHourMinuteSecondDatePickerElementFlag} ¬
waitUntilDone:true
if returnCode = (NSAlertSecondButtonReturn) then error number -128
tell application "Numbers" to tell the front document to tell active sheet to tell (first table whose class of selection range is range)
repeat with c in (get selection range)'s cells
set value of c to my date
end repeat
end tell
end run
on showDatePicker:params
local params
set {PickerStyle, PickerElements} to params
tell NSDatePicker's alloc()
initWithFrame_({{0, 0}, {100, 100}})
setDatePickerStyle_(PickerStyle)
setDatePickerElements_(PickerElements)
setDateValue_(current date)
set fittingSize to fittingSize()
setFrameSize_(fittingSize)
set View to NSView's alloc()
View's initWithFrame:{{0, 0}, {100, 175}}
View's setFrameSize:fittingSize
View's addSubview:it
tell NSAlert's alloc()
init()
setMessageText_("Pick a date and time")
setInformativeText_("Any date")
addButtonWithTitle_("OK")
addButtonWithTitle_("Cancel")
setAccessoryView_(View)
set returnCode to runModal()
end tell
set my date to dateValue() as date
end tell
end showDatePicker:
---------------------------------------------------------------------------❮END❯