• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get Zero (0) before Month ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get Zero (0) before Month ?


  • Subject: Re: How to get Zero (0) before Month ?
  • From: Michelle Steiner <email@hidden>
  • Date: Sun, 16 Feb 2003 09:56:00 -0700

On Sunday, February 16, 2003, at 08:35 AM, Krister Nyman wrote:

I get result "2003/2/16" thats great, but I wonder how to get this
"2003/02/16" ?

set the_months to "January February March April May June July August September October November December"
set message_date to current date
set mess_year to year of message_date as string
set mess_day to day of message_date as string
if day is less than 10 then set mess_day to "0" & mess_day
set mess_month to month of message_date as string
repeat with x from 1 to count words in the_months
if mess_month = word x of the_months then
set month_count to x as string
exit repeat
end if
end repeat
if x is less than 10 then set month_count to "0" & month_count
set date_format to mess_year & "/" & month_count & "/" & mess_day

Note that I changed the method of prepending the zero in the day to the same method as I use for the month. I also rewrote the loop to exit as soon as the month is found.

--Michelle

--
"There's some good in the world, Mr. Frodo, and it's worth fighting for."
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
References: 
 >How to get Zero (0) before Month ? (From: Krister Nyman <email@hidden>)

  • Prev by Date: Re: Using ticks in AS Studio??
  • Next by Date: Newbie Question: Script Objects
  • Previous by thread: How to get Zero (0) before Month ?
  • Next by thread: Re: How to get Zero (0) before Month ?
  • Index(es):
    • Date
    • Thread