• 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: current date - 1 day
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: current date - 1 day


  • Subject: Re: current date - 1 day
  • From: Stephen Schaefer <email@hidden>
  • Date: Tue, 17 Feb 2004 03:28:10 -0500

Thanks all. I was just fiddling w/ an example from Applescript in a Nutshell (hence set d to day of theDate...just copying here), since what I'm working toward is to building definitions of certain objects by a range of today - N amount of days. Now I know.


On Feb 17, 2004, at 2:23 AM, John W. Baxter wrote:

On 2/16/2004 22:59, "Stephen Schaefer" <email@hidden> wrote:

Probably simple newbie question, so hopefully a simple answer: why
does "yesterday" result in "-86383" instead of 16 (as in today is the
17th, so yesterday would be the 16th)? Thanks

set theDate to current date
set d to day of theDate
The d variable now contains 17. This is measured in days from the first of
the month.
set m to month of theDate
set y to year of theDate
set ts to time string of theDate
set yesterday to (d) - (1 * days)
[1 * days is 86400, the number of seconds in a day.]
The yesterday variable now now contains 17 - 86400, or -86383
set mesg to "Here's info about today:" & return & ,
"time: " & ts & return & ,
"day: " & d & return & ,
"month: " & m & return & ,
"year: " & y & return & ,
"yesterday: " & yesterday & return
display dialog mesg

Use either something based on
set yesterday to (current date) - (1 * days) --it's now a date type
or based on
set yesterday to d - 1 --it's now an integer number of days, and you'll
have problems on the first of the month
depending on which you want.

--John
_______________________________________________
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.
_______________________________________________
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.

  • Prev by Date: Re: current date - 1 day?
  • Next by Date: Re: Launching TextEdit with a TEXT document
  • Previous by thread: Re: current date - 1 day?
  • Next by thread: Reply to "Re:Launching TextEdit with a TEXT document", of Craig Hoyt.
  • Index(es):
    • Date
    • Thread