-- This script will take a date typed into a dialog box in "plain English" such as jan 22 2003, or a similar date in the clipboard and return it as day, month, year numbers separated by the symbol of choice (/, :, n dash, period, space, or nothing) in the order chosen. It returns the result to the clipboard. It relies on a handler derived from one by Nigel Garvey found in DateTips on ScriptBuilders.net.
set Q to display dialog "Enter a date" default answer "" buttons {"From Clipboard", "Use Entry"} default button 2
if button returned of Q = "From Clipboard" then
try
set CurDate to date (the clipboard)
on error
display dialog "The Clipboard did not contain a valid date" buttons {"Oops"} default button 1
return
end try
else
set CurDate to date (text returned of Q)
end if
set Separator to first character of ((choose from list {"/ slash", ": colon", "“ n dash", ". period", " Space", "None"} with prompt "Choose a delimiter for your numerical date" without multiple selections allowed and empty selection allowed) as text)
if Separator = "N" then set Separator to ""
set Order to first character of ((choose from list {"1) Month/Day/Year", "2) Day/Month/Year", "3) Year/Month/Day"} with prompt "Choose the format of the numerical date" without multiple selections allowed and empty selection allowed) as text) as number
set the clipboard to FormatDateAsNumbers(CurDate, Separator, Order)
to FormatDateAsNumbers(DateIn, sptr, Ordr) -- from a script in DateTips by Nigel Garvey
tell {DateIn}
copy beginning to end
set end's month to January
tell ((beginning's year) * 10000 + (beginning - (end - 3944592)) div 2629728 * 100 + (beginning's day)) as string
return item Ordr of {text 5 thru 6 & sptr & text 7 thru 8 & sptr & text 1 thru 4, text 7 thru 8 & sptr & text 5 thru 6 & sptr & text 1 thru 4, text 1 thru 4 & sptr & text 5 thru 6 & sptr & text 7 thru 8}
end tell
end tell
end FormatDateAsNumbers