Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Ok I must be missing something. I have a section with the "last updated date" in a text cell, I'd like it to autoupdate. Is there a "insert current date" command hidden away in some menu?

share|improve this question

closed as off-topic by m_goldberg, Kuba, Sjoerd C. de Vries, rasher, Oleksandr R. Apr 23 at 0:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – m_goldberg, Kuba, Sjoerd C. de Vries, rasher, Oleksandr R.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
When should it be updated? –  Kuba Apr 22 at 15:28

2 Answers 2

If you want this done automatically then the way I would do it is to time stamp the notebook as you close it, i.e. the time stamp appears after "Last modified".

This code might be overkill but it will do the job:

Create a text cell with "Last Modified " in it and give it a cell tag (in this example "LastModified"), then ...

SetOptions[EvaluationNotebook[], 
 NotebookEventActions :> {"WindowClose" :> 
    Module[{dy, hr, mn}, {dy, hr, mn} = 
      Map[(LinkWrite[First[$FrontEnd], FrontEnd`Value[#]]; 
             LinkRead[First[$FrontEnd]]) &, {"DateLong", "Hour", 
        "Minute"}]; NotebookLocate["LastModified"]; 
     NotebookWrite[InputNotebook[], 
      Cell[TextData[{"last modified ", dy, " at ", hr, ":", mn}], 
       "Text", CellTags -> "LastModified"]]]}
 ]
share|improve this answer

If you want the message to show when you last run that command, all you have to do is add this to the cell you're evaluating:

message = DateString[DateList[]]  ;
Print["This was last updated on  " <> message]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.