I’m trying to do the following:
- Get the current date.
- See if the current date is in the list.
- if the current date is in the list return “Today”.
set vacationDay to {"4/20/06"} as string
set valE to (item 1 of vacationDay) as string
set outPutEE to "Today"
set currentDate to current date
short date string of currentDate
tell application "Finder"
if valE = currentDate then
outPutEE
end if
end tell
Is there another data type that I have to make the list? Any help would be appreciated.
On the first line, you turned the list into a string. On the next line, you try to get the first item of that string, which will now be “4”.
The format of “Short date string” is dependant on an individual’s date/time settings.
There is no need for the Finder in this script.
Here are a couple of ideas.
set vacationDay to {"4/20/06"}
set valE to (item 1 of vacationDay)
tell (current date) to set currentDate to "" & (it's month as integer) & "/" & it's day & "/" & (text -2 thru -1 of (it's year as text))
if valE = currentDate then
"Today"
end if
set vacationDays to {"4/20/06", "5/29/06"}
tell (current date) to get "" & (it's month as integer) & "/" & it's day & "/" & (text -2 thru -1 of (it's year as text))
if vacationDays contains result then
"Today"
end if
Thanks for the help. exactly what I need. Greatly appreciate the insight.
The Unix date command is a pretty useful tool too, as it allows flexible formatting with easy to read code. The following returns the date in mm/dd/yy format:
do shell script "date +%m/%d/%y"
When getting the current date, it certainly is. (It’s my preferred way, actually.) However, it doesn’t help when you need to format a date object. Also, note that the particular format used in the above example will add some leading zeros to single digit numbers.
Bruce, can you make the above shell script give the year in a four figure format?
kiwilegal:
Capitalize the Y. date +%m%d%Y = 09052008
Play around with capitalizing (and not) to get different results.
Enjoy!
Jim Neumann
BLUEFROG