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β
- Navigate to a Vessel with a field that you want to include a date.
- In the field, reference the Platform environment variables related to the Fleet or Vessel's Start Time. A full list of Platform 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.
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 Output | Field Entry |
---|---|
report_09-21-2022.csv | report_${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.csv | report_${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).csv | report(${SHIPYARD_VESSEL_START_TIME_HOUR} :${SHIPYARD_VESSEL_START_TIME_MINUTE} :${SHIPYARD_VESSEL_START_TIME_SECOND} ).csv |