I have a current script that creates the date, but it includes the time, too. I don't want that

I have a script that generates groups in Devonthink, but also generates an entry in a numbers file that is stored in Devonthink. The date includes the time and I don’t want the time because it messes up the sort in numbers. This is what the (sample) date looks like: 2022-12-14 3:01:26 PM. This is what I’d like the date to look like 2022-12-14. I have found a script that explains how to make the date this format. This is that script: (gratefully and greatly guided by DTLow for this script) :
[For interest and a fuller explanation of the entire script here’s the link to my original query: [Script which can create a project folder (a sub folder) from text from the clipboard?](https://Create project folders in Devonthink and finder as well as project numbers]

set {year:y, month:m, day:d} to (current date)
# pad the day and month if single digit
set day_str to text -1 thru -2 of ("00" & d)
set mon_str to text -1 thru -2 of ("00" & (m * 1))
# make ISO8601 date string without time
set theDate to (y & "-" & mon_str & "-" & day_str) as string

This is the (portion) script that I have to generate the date etc within the numbers file in Devonthink:

----------------------------
		tell application id "com.apple.iWork.Numbers"
			activate
			delay 1
			tell table 1 of sheet 1 of document 1
				set projNo to (value of cell 4 of last row) + 1 as integer as text
				set projName to (text returned of (display dialog "Enter Project Name" default answer "New Project"))
				set company to (text returned of (display dialog "Company" default answer "Company"))
				set contact to (text returned of (display dialog "Contact" default answer "Contact"))
				set details to (text returned of (display dialog "Details" default answer "Details"))
				set supplier to (text returned of (display dialog "Supplier" default answer "Supplier"))
				add row below last row
				set value of cell 2 of last row to current date
				set value of cell 4 of last row to projNo
				set value of cell 5 of last row to projName
				set value of cell 6 of last row to company
				set value of cell 7 of last row to contact
				set value of cell 8 of last row to details
				set value of cell 11 of last row to supplier
			end tell
			close document 1 saving yes
			delay 0.1
			quit
		end tell

How do I combine these two to achieve the results I would like? I get jammed because of the initial line " Set value of cell 2 of last row to current date" – the modified date used the same command “set”.

Note, this isn’t generating the date within the Numbers file in DEVONthink.
This is also a Numbers script, not a DEVONthink one.

But this line isn’t using the variable you set…

set value of cell 2 of last row to current date

It should be…

set value of cell 2 of last row to theDate

1 Like

Thank you @BLUEFROG! I added the variable and all is running as I had hoped.

You’re welcome :slight_smile: