Dates can be difficult objects to work with in AppleScript.
With regard to the listed problems:
1.) AppleScript will display interpreted values with the script editor. To do extraction of strings on dates, get the whole date value converted as a string and then extract words of that string to get the date elements. The following is a working AppleScript example.
get current date
copy the result to today
copy today as string to DateString
-- "Monday, October 10, 1994 12:05:51 PM"
display dialog "Today is " & word 1 of DateString
display dialog "This month is " & word 2 of DateString
display dialog "This is day " & word 3 of DateString & " of month " & word 2
of DateString
display dialog "The year is " & word 4 of DateString
set hr to word 5 of DateString
set mn to word 6 of DateString
set sc to word 7 of DateString
set AMPM to word 8 of DateString
display dialog "The time is " & hr & ":" & mn & ":" & sc & " " & AMPM
2.) What you see in the script editor log window is often an interpretation of AppleScript's internal representation of the data. While AppleScript may be representing something internally as an index or a number, it displays something more meaningful for the observer to interpret. What you are seeing is an example of this. Attempts to display class representations will show you the four character AppleScript internal types.
Using the following AppleScript fragment, you can compile a table of some of the AppleScript internal types.
(*
set x to "A" -- string
set x to 1 -- integer
set x to 1.5 -- real
set x to current date -- date
set x to false -- boolean
set x to {1, 2, "A"} -- list
set x to {text returned:"text entered", button returned:"OK"} -- record
set x to application -- class
*)
set x to {1, 2, "A"} -- list
display dialog (class of x)
get class of x
AppleScript Expression | Internal Type | Interpreted by Script Editor |
"A" | TEXT | string |
1 | long | integer |
1.5 | doub | real |
current date | Idt | date |
true or false | bool | boolean |
{1,2,"A"} | list | list |
{fnm:"Doug",lnm:Korns"} | reco | record |
application | pcls | class |