Changing a long date to a short date

Hi,
Could someone tell me how to change a long date like Friday, May 13, 2005 into a short date like 05/13/05? I need to do this because when I tell Applescript to take Friday, May 13, 2005 from 26/5/05 I get some huge number… :confused:

I would be really grateful for any help :slight_smile:

Model: Power Mac G5
Browser: Safari 412
Operating System: Mac OS X (10.4)

Either of these should work:

set theDay to day of (current date) as string
set theMonth to month of (current date) as integer
set theYear to year of (current date)

set shortDate to theDay & "/" & theMonth & "/" & theYear

set shortDate to do shell script "date +%d/%m/%y"

Hi Elijah,

Also:

set myDate to "Friday, May 13, 2005"
set myShortDate to short date string of (date myDate) --> "13/5/05"

The long number you are getting is the difference in seconds. Divide this by 86400 (60 * 60 * 24) to get days.

Best wishes

John M

Very nice, John. I was unaware you could do that.

Or, since AppleScript has time constants for seconds, minutes, hours, & days, you can just use:

set date_1 to "May 13, 2005"
set date_2 to "May 26, 2005"
return ((date date_2) - (date date_1)) / days

Jon

Very neat.

Hi everyone,

Thank you all for the great suggestions, they are all really handy tips to know. That seems so obvious that it was coming out as seconds now…

I used jonn8’s one in the end, just an extra 5 letters! D’oh!

:slight_smile:

Thanks again!