• 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: Another question on dates and times
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another question on dates and times


  • Subject: Re: Another question on dates and times
  • From: Clint Hoxie <email@hidden>
  • Date: Tue, 4 Dec 2007 21:45:03 -0700

Ummm...thanks. I was trying to parse the parts so that they would display in a text string. As my first line in the post suggested, I don't know what resource to go to for finding the right commands and syntax to use.

Date strings/fields/variables are handled differently than text-only strings/fields/variables. So...I needed a way to try turning it into "text" parts...which I said didn't work. Neither did the simpler version.

What you gave me looks like it would work...and I would likely never find the way to do that without just asking (which I did) because there isn't an obvious resource that I can find within the AppleScript menus (like would be in many other apps meant to be used by the semi- intelligent and self-reliant user).

Anyway. Thanks for the help. The breakdown into parts is left over formula coding from using Excel for years. I thought the same type of syntaxing might work.

Clint


On Dec 4, 2007, at 9:13 PM, Gary (Lists) wrote:

"Clint Hoxie" wrote:

Please tell me what resource I can use to figure this stuff out. I just flat
don't know where to look, beyond the descriptions in the libraries.


Anyway, I am getting an error which looks to be telling me that a date can't
be returned as a string.


Here is the code.

--Set variable for default to current date plus one day
set TomorrowDate to (month of (current date)) + 60 * 60 * 24 & "/" & (day of
(current date)) + 60 * 60 * 24 & "/" & (year of (current date)) + 60 * 60 *
24\

I have an idea what you want to do, but I have no idea why you think that
would do it. ;)


You don't add a day full of seconds to the month or the year just to get
another day. Just add it to the day, while it's still a date, and you'll be
fine.


(In AppleScript, saying "a date" means that the result is an special class
of object. It is a 'date' object.)



current date -- date "Tuesday, December 4, 2007 10:58:40 PM"

(current date) + (60 * 60 * 24)
 --  date "Wednesday, December 5, 2007 10:59:02 PM"

What does that tell us?

It tells us that if you add (implied) seconds to a date, you get a date.

So, add your day of seconds to today to get tomorrow. Since that is still a
'date object', you can then get the month/day/year parts from it as you
would from 'current date'.


-- Here's a working script that achieves your goal, I think:
--
set tod_ to current date
set tom_ to (today_ + (60 * 60 * 24))
-- next line is a single line
set tomString_ to "" & (month of tom_ as integer) & "/" & (day of tom_) &
"/" & (year of tom_)
--> "12/5/2007"


display dialog "blah" default answer tomString_

--
Gary


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Another question on dates and times
      • From: "J. Stewart" <email@hidden>
    • Re: Another question on dates and times
      • From: Michelle Steiner <email@hidden>
References: 
 >Re: Another question on dates and times (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: Another question on dates and times
  • Next by Date: Re: Wow, AppleScript is tough!
  • Previous by thread: Re: Another question on dates and times
  • Next by thread: Re: Another question on dates and times
  • Index(es):
    • Date
    • Thread