Timestamp

Does anyone know how to create a time stamp?


I want to timestamp when we receive a deposit on our invoices, does anyone know how to do this?


I keep seeing circular reference and iterative calculations videos pop up for excel videos on YouTube but I do not see athese options for apple numbers


please help thank you !




Posted on Nov 26, 2021 1:40 PM

Reply
Question marked as Top-ranking reply

Posted on Nov 27, 2021 5:47 PM

There is no way of doing this using Numbers' calculation formulae. As Barry says, they are 'live' functions and will be recalculated whenever there is any change to the table.


However, you can use Automator and AppleScript.


First, launch Automator.


In the New Workflow dialog, choose Quick Action:



This will create a new Automator Workflow.


First, modify the settings in the top right:



Workflow receives no input in Numbers


Now drag a Run AppleScript action from the sidebar into the workflow window:





Delete all the default content from the Run AppleScript workflow:



Copy and paste the following into the Run AppleScript action:


on run
	set today to current date
	set today_string to hours of today & ":" & minutes of today & " " & day of today & " " & month of today & " " & year of today as text
	tell application "Numbers"
		activate
		tell document 1
			tell sheet 1
set active_table to first table whose selection range's class is range
tell active_table
					set selectedCell to name of selection range
					set value of cell selectedCell to today_string
				end tell
			end tell
		end tell
	end tell
end run


Click the Hammer Button at the top of the Workflow action to check your AppleScript syntax. If all is well, your Workflow window should look like this:




Save and close the Automator Workflow. I used the name DateStamp.


In Numbers, select a cell. From the Numbers menu, choose Services and then the name of your Workflow:



Choose DateStamp (or whatever you called your Workflow) and the time and date will be hardcoded into the selected cell:



If you don't have a cell selected, or if you select multiple cells, you will get errors. These can be handled, but I've stuck to the bare bones here.


If you get security questions about Automator controlling Numbers, or AppleScript controlling Numbers, then Allow.


Hope this helps,


H









12 replies
Question marked as Top-ranking reply

Nov 27, 2021 5:47 PM in response to SneakPeak01

There is no way of doing this using Numbers' calculation formulae. As Barry says, they are 'live' functions and will be recalculated whenever there is any change to the table.


However, you can use Automator and AppleScript.


First, launch Automator.


In the New Workflow dialog, choose Quick Action:



This will create a new Automator Workflow.


First, modify the settings in the top right:



Workflow receives no input in Numbers


Now drag a Run AppleScript action from the sidebar into the workflow window:





Delete all the default content from the Run AppleScript workflow:



Copy and paste the following into the Run AppleScript action:


on run
	set today to current date
	set today_string to hours of today & ":" & minutes of today & " " & day of today & " " & month of today & " " & year of today as text
	tell application "Numbers"
		activate
		tell document 1
			tell sheet 1
set active_table to first table whose selection range's class is range
tell active_table
					set selectedCell to name of selection range
					set value of cell selectedCell to today_string
				end tell
			end tell
		end tell
	end tell
end run


Click the Hammer Button at the top of the Workflow action to check your AppleScript syntax. If all is well, your Workflow window should look like this:




Save and close the Automator Workflow. I used the name DateStamp.


In Numbers, select a cell. From the Numbers menu, choose Services and then the name of your Workflow:



Choose DateStamp (or whatever you called your Workflow) and the time and date will be hardcoded into the selected cell:



If you don't have a cell selected, or if you select multiple cells, you will get errors. These can be handled, but I've stuck to the bare bones here.


If you get security questions about Automator controlling Numbers, or AppleScript controlling Numbers, then Allow.


Hope this helps,


H









Nov 27, 2021 6:08 PM in response to SneakPeak01

SneakPeak01 wrote:

Does anyone know how to create a time stamp?


Like the other suggestions this is not fully automatic, but with the cell selected it's really quick and easy to choose Insert Current Date or Insert Current Time from the Table menu or, even faster, just hit the keyboard shortcut option-shift-command-d or option-shift-command-t.




SG

Nov 27, 2021 6:45 PM in response to SGIII

Somewhat irritatingly (thanks, Numbers programmers), the simpler solution provided by SG doesn't include seconds, or any way of combining date and time. If you need seconds, then try the following modification to the AppleScript in my original post. You can also tweak the line beginning


set today_string to...


to create any combination of seconds, minutes, hours, days, months and years in a single cell.


I've included some error handling/avoiding for no selection and multiple selection:


set today to current date
set today_string to hours of today & ":" & minutes of today & ":" & seconds of today & " " & day of today & " " & month of today & " " & year of today as text
tell application "Numbers"
	activate
	tell document 1
		tell sheet 1
			try
				set active_table to first table whose selection range's class is range
			on error
				display alert "No cell selected"
				return
			end try
			tell active_table
				set selectedRange to name of selection range
				set firstCell to word 1 of selectedRange
				set value of cell firstCell to today_string
			end tell
		end tell
	end tell
end tell


You should of course be aware that you can run this Quick Action on any cell, and it will replace the original data or formula in that cell.



Nov 27, 2021 7:57 PM in response to HD

I don't like the pink, but haven't had time to figure out how to change it (recently moved to Monterey, a smooth transition).


I think it was Barry who suggested NOW() or TODAY() above in this thread. He may be still running quite an old version of Numbers that hasn't incorporated the convenient new menu picks for date and time stamps.


On my machine Table > Insert Current Time (or shift-control-command-t) definitely inserts the seconds by default in the value of cell. It also inserts the date.


Setting the Data Format on a whole column to display seconds, or both Date and Time, is a one-time thing, of course. It doesn't have to been done for each time stamp. For me, not onerous.


Once the desired Data Format is applied to the column (which can be set display the date and seconds) a quick shift-control-command-t is all it takes to insert a stamp. (No need to double-click and go to the old Insert > Date & Time.)




Services/Quick Actions and AppleScripts are great. Hope you keep them coming. I was just studying your workaround for the recently introduced selection range bug. Thanks for that.


SG






Nov 26, 2021 4:52 PM in response to SneakPeak01

You can insert the date and time using the NOW function, BUT NOW and TODAY are both 'live functions, and will refresh every time there is a change in the table. You can also Insert the current Date and Time as a fixed value using the Insert Date and Time menu item in the Edit menu.


Here are the steps:

  • Click on the cell to receive the D&T value. Click a second time to place the insertion point in the cell.

  • With the insertion point blinking in the cell, go to the Edit menu and choose Inset Date and Time. (You will see the Date in the cell.)
  • Without leaving the cell, click the Date shown to open the menu seen in the image below, and choose the format in which you want to see the Date and Time value displayed:


Semi automatic way using NOW, then converting the formula result to a fixed value.


Assuming your will want to D&T stamp all rows in the same column, and want to apply the D&T stamp as each row is filled:


  • Select the first cell in the column that will hold the D&T stamp (B2 in the example) , type = to open the Formula editor, and enter the formula shown in the editor below the selected cell:

  • Type an x (or any value) in A2, and press return to confirm the entry and trigger the formula.
  • Place the pointer close to the bottom edge of B2, then drag the yellow circle down to fill the formula into the rest of the column.
  • Delete the text in A2 to remove the D&T value in B2.


To use the formula and immediately convert the stamped value to a fixed value:


  • Enter the trigger value in A2 to make NOW to calculate and display the current Date & Time value in B2.
  • Click once on B2, then press command-C to Copy.
  • With B2 still selected, go the the edit menu and choose Paste Formula Results.


This replaces the formula in B2 with the last result it calculated, giving you a permanent time stamp in that cell.


Regards,

Barry


Nov 27, 2021 7:08 PM in response to HD

Well, what happens if you change the Data Format to display the seconds too?


On my machine the seconds are definitely there.


I find it much easier to use the built-in functionality than to construct and install an Automator Service or go through NOW() and TODAY() route. Those solutions were applicable to old versions of Numbers years ago, but are no longer necessary.


Now a simple menu pick or keyboard shortcut does the trick.


SG



Nov 27, 2021 7:18 PM in response to SGIII

SGIII wrote:

Well, what happens if you change the Data Format to display the seconds too?


It displays the seconds. But not by default, I have to change the cell formatting, which is even less automatic.

On my machine the seconds are definitely there.

On my machine they aren't by default. See the screenshot.

I find it much easier to use the built-in functionality than to construct and install an Automator Service or go through NOW() and TODAY() route. Those solutions were applicable to old versions of Numbers years ago, but are no longer necessary

Sorry, but I'm really old. I didn't suggest NOW() or TODAY(), but I still think Quick Actions have their uses.

Now a simple menu pick or keyboard shortcut does the trick.

Unless you want to combine date and time in one cell without pre-formatting.

SG

HD


(Loving your pink menu bar BTW)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Timestamp

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.