Skip to main content

How to Insert a Date into any Field

Overview​

When you are sending a report to a stakeholder or automate uploading a file, you may want to include the current date or time in the file name to let your stakeholder know when the report was ran.

Steps​

  1. Navigate to a Vessel with a field that you want to include a date.
  2. In the field, reference the Shipyard environment variables related to the Fleet or Vessel's Start Time. A full list of Shipyard environment variables can be found here.

Ex. ${SHIPYARD_FLEET_START_TIME_YEAR}-${SHIPYARD_FLEET_START_TIME_MONTH}-${SHIPYARD_FLEET_START_TIME_DAY}. This will return a string with year-month-date. Feel free to add any other information before or after the date setup, but never inside the ${} environment variable reference.

Pro-Tip

If you need to reference the file name again downstream, we recommend using FLEET_START_TIME variables because these times will be unchanging throughout the current run.

If you want the time to be different for every Vessel, use the VESSEL_START_TIME variables. This will require you to use regex match to find the file name downstream in the same Fleet.

Other Date Examples​

Here are some other general use-cases:

Example OutputField Entry
report_09-21-2022.csvreport_${SHIPYARD_VESSEL_START_TIME_MONTH}-${SHIPYARD_VESSEL_START_TIME_DAY}-${SHIPYARD_VESSEL_START_TIME_YEAR}.csv
2022/09/report.csv${SHIPYARD_VESSEL_START_TIME_YEAR}/${SHIPYARD_VESSEL_START_TIME_MONTH}/report.csv
1663769254_report.csv${SHIPYARD_VESSEL_START_TIME_EPOCH}_report.csv
report_09-21-2022_14:07.csvreport_${SHIPYARD_VESSEL_START_TIME_MONTH}-${SHIPYARD_VESSEL_START_TIME_DAY}-${SHIPYARD_VESSEL_START_TIME_YEAR}_${SHIPYARD_VESSEL_START_TIME_HOUR}:${SHIPYARD_VESSEL_START_TIME_MINUTE}
report(14:07:34).csvreport(${SHIPYARD_VESSEL_START_TIME_HOUR}:${SHIPYARD_VESSEL_START_TIME_MINUTE}:${SHIPYARD_VESSEL_START_TIME_SECOND}).csv