Calculate Time Difference Between Two Dates in LabVIEW

Updated Oct 23, 2023

Environment

Software

  • LabVIEW

  • In LabVIEW, how do I calculate the time difference in weeks, days, hours, and/or minutes between two given dates?
  • How do I calculate the time period between two dates?
  • Given a timestamp, is there a function in LabVIEW that will return the calendar week of the year?

To calculate the time difference between two dates in weeks, days, hours, and/or minutes:

Use the Format into String VI
1. Place Format into String VI on the block diagram
2. Right click the "resulting string" output of the Format into String VI and select Create > Indicator.
3. Place two Time Stamp Constants and one Subtract Function on the block diagram. Connect as shown in the example below. In this example, the Elasped Time = Comparison Date - Reference Date.
4. Lastly, place a String Constant on the block diagram and connect  it to the Format into String VI through the "format string" terminal as shown below. You can customize the string format based on your needs by using the Time Stamp Format Codes

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.