MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ben Waldie <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 16:45:49 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
WES,

On Wednesday, May 21, 2003, at 03:40 PM, Eric Schult wrote:

> WOW! That's a mouthful of code! You're a lifesaver. But now I'm really
> starting to mourn the loss of Tanaka's. The stampToDate command can
> handle a
> string to date coercion as simply as this:
>
> set dateString to "05212003"
> set myDay to ((characters 3 thru 4 of dateString) as string)
> set myMonth to ((characters 1 thru 2 of dateString) as string)
> set myYear to ((characters 7 thru 8 of dateString) as string)
> set myTime to "000000"
> set myDate to StampToDate (myYear & myMonth & myDay & myTime)

If you know where the day, month, and year will be, you can reformat
the date to a short date string using a delimiter to separate the
items.  Then, you can coerce the short date string to a date.  I.e. -

set theDelimiter to "."
-- OR
set theDelimiter to "-"
-- OR
set theDelimiter to "/"

set theDate to "05212003"
set theMonth to text 1 thru 2 of theDate
set theDay to text 3 thru 4 of theDate
set theYear to text 5 thru 8 of theDate
set theDate to theMonth & theDelimiter & theDay & theDelimiter & theYear

date theDate
--> RETURNS - date "Wednesday, May 21, 2003 12:00:00 AM"

Thanks,

- Ben

Benjamin S. Waldie
Automated Workflows, LLC
=============================================
AppleScript and Workflow Automation
Consulting - <http://www.automatedworkflows.com>
AppleScript Info - <http://www.applescriptguru.com>
AppleScript Training - <http://www.applescripttraining.com>
=============================================

ATOM RSS1 RSS2