RE: Coercing date to real
RE: Coercing date to real
- Subject: RE: Coercing date to real
- From: email@hidden
- Date: Thu, 7 Feb 2002 02:15:55 EST
>
Can't make date "Tuesday, April 4, 1995 11:06:00 PM" into a real.
try pulling the date as the ticks (the number of seconds):
set UniqueID to the ticks of checkID as real
OR Just
set UniqueID to the ticks of checkID
From one of my scripts:
-- grab the current date
set Now to the current date
-- force the BirthDate variable to record type date by loading the
current date
set BirthDate to the current date
-- change the BirthDate variable to the actual date we want
set the year of BirthDate to 1965
set the month of BirthDate to September
set the day of BirthDate to 23
-- force the DeathDate variable to record type date by loading the
current date
set DeathDate to the current date
-- change the DeathDate variable to the actual date we want
set the year of DeathDate to 2032
set the month of DeathDate to March
set the day of DeathDate to 23
-- figure out the number of seconds between the Birthdate and now
set Difference to (Now - BirthDate)
-- convert that number into the number of days between the Birthdate and
now
set NumOfDays to (((Difference / 60) / 60) / 24) as integer
-- rip it into two separate integers, so we can display it as xx,xxx later
set ThousandsOfDays to (round (NumOfDays / 1000) rounding down)
set RestOfDays to (NumOfDays - (ThousandsOfDays * 1000))
-- figure out the number of seconds between the expected date of death
and the birthdate
-- i.e. the number of seconds in your life!
set LifeExpectancy to (DeathDate - BirthDate)
-- convert that number into the number of days in the expected lifespan
set NumOfLifeDays to (((LifeExpectancy / 60) / 60) / 24) as integer
-- calculate the lifespan completed as a number that can be displayed as
a percentage in the form xx.xx%
set Expectancy to ((round ((NumOfDays / NumOfLifeDays) * 10000) rounding
down) / 100)
-- show your answers
display dialog "Today is day " & ThousandsOfDays & "," & RestOfDays & "
in the life of CP. " & return & Expectancy & "% of Life Expectancy reached."
buttons {"OK"}
_______________________________________________
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.