0

How do I pad or add leading zeros to months? For example, May would return "05"

set the_month_new to button returned of (display dialog "Choose a month:" buttons {"April", "May", "June"})

(run script the_month_new) as integer
1
  • Is that really how you are getting the months?
    – red_menace
    Commented Sep 11, 2021 at 4:17

1 Answer 1

1

Try the following.

set the_month_new to button returned of (display dialog "Choose a month:" buttons {"April", "May", "December"})

set the_month to (run script the_month_new) as integer

if the_month is less than 10 then
    set the_month to "0" & the_month
else
    set the_month to the_month as string
end if

 

0

You must log in to answer this question.

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