• 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: Date mathematics help please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date mathematics help please


  • Subject: Re: Date mathematics help please
  • From: Paul Berkowitz <email@hidden>
  • Date: Sat, 18 Jan 2003 17:36:53 -0800

On 1/18/03 5:25 PM, "roy whelden" <email@hidden> wrote:

> Dates are very convenient to work with in Applescript. Here is an
> example which should answer your question.
> -------------------------------
>
> set x to date "Tuesday, January 14, 2003 12:00:00 AM"
> set y to date "Friday, January 17, 2003 12:00:00 AM"
>
> set z to y - x --this returns the difference in seconds
>
> set hoursDifference to z div hours --(1) use div to return an integer;
> (2) hours is an Applescript constant. Days,weeks, and minutes are also
> Applescript constants

To get the minutes, continue:

set secsLeftOver to z mod hours
set minutesPart to secsLeftOver div minutes
set secsLeftOver to secsLeftOver mod minutes

You may not need the seconds, I seem to recall.

'mod' gives the remainder, 'minutes' is simply a shorthand constant for 60,
and hours a constant for 3600, etc.

--
Paul Berkowitz
_______________________________________________
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: 
 >Re:Date mathematics help please (From: roy whelden <email@hidden>)

  • Prev by Date: Curse of the Tongs
  • Next by Date: Re: Entourage 'import' command
  • Previous by thread: Re:Date mathematics help please
  • Next by thread: Curse of the Tongs
  • Index(es):
    • Date
    • Thread