Show today's date on chart

I’m surprised I need to ask this question. Calc charts present data graphically. Many data are time-sensitive, in which case it is important to show the date the data were generated. If the chart is to be exported as an image, the date must be incorporated in the chart itself. How can this be done?

There seems to be no way the ‘Today()’ function can be included either in a Title or Subtitle element or in a form field superimposed on the chart. Any suggestions would be most welcome.

Hello,

please see the answer to question Adding a cell reference to a chart text box, which provides a solution without using a macro.

Just replace text This shows the Linked cell by function =TODAY() (or any other dynamic text you want to appear on your chart) on cell A23 of the example shown in the answer (of course you man need to adapt to your special use case).

Hope that helps.

If the answer helped to solve your problem, please click the check mark (:heavy_check_mark:) next to the answer.

Thanks Opaque. Simple but elegant solution.

Hello,

This can be done via a macro. Based upon previous question already have the basis for what is needed. It is just a matter of it being either the main or sub title.

Here s a mock (from last question) of your chart:

image description

Adding these lines to the end of you existing macro:

  oEmbeddedObject = oChart.getEmbeddedObject()
Rem Set for Main Title
  oEmbeddedObject.HasMainTitle = TRUE
  oEmbeddedObject.Title.String = "Main As of: " & Now()
Rem Set for SubTitle
  oEmbeddedObject.HasSubTitle = TRUE
  oEmbeddedObject.SubTitle.String = "Sub As of: " & Now()

Here is the result:

image description

I like this, Ratslinger, but I want only the date, not time, so tried with Today() but this does not seem to work. Have gone with Opaque’s solution for now. Many thanks anyway to both of you.

@bbater,

Always the choice is dependent upon your needs. I personally would want a time but the format is an easy change:

oEmbeddedObject.SubTitle.String = "Sub As of: " & Format(Now(), "YYYY-MM-DD")

or:

oEmbeddedObject.SubTitle.String = "Sub As of: " & Format(Now(), "DD/MM/YYYY")

or some other choice.