Book a Demo

Author Topic: How to print the model date in a script?  (Read 3977 times)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
How to print the model date in a script?
« on: January 31, 2022, 08:44:16 pm »
I would like to have my script print the last modification date/time of the current EA model. I know how to do this with the DocumentGenerator but I am not using that in this particular script.

Preferably, I would like to be able to access the modification date/time of the running script itself, would that be possible?


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to print the model date in a script?
« Reply #1 on: January 31, 2022, 08:49:29 pm »
Probably the easiest way is to run a SQL over t_object and get the most recent modification date. Depends on the type of SQL you are using to obtain the first record only.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to print the model date in a script?
« Reply #2 on: January 31, 2022, 09:11:08 pm »
The scripts themselves can be found in t_script, but the don't store a modification date, so not really possible.

As for the last modified date on the model, there are modifiedDates in both t_object as t_diagram.

I guess if you take the most recent of the two you'll be close to the last modified date.
It's not 100% accurate as I can still change other thing (connectors, attributes, tests, etc...) without affecting any of these modification dates, but it is probably close enough.
In SQL server that query could be

Code: [Select]
select top (1) m.ModifiedDate
from
(select o.modifiedDate from t_object o
union
select d.ModifiedDate from t_diagram d) m
order by m.ModifiedDate desc


Geert