LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing current date time with file creation date and time

The idea is to fetch the date and time a file was created then compare it to the current system date and time. Required output is the number of months, days and time that elapsed since the file was created. If the file is more than six months old, an external application (.exe) will be launched to create a new version of the file. How do I implement all of this in LabVIEW?

 

 

 

 

0 Kudos
Message 1 of 6
(3,994 Views)

Hi FVallent,

 

this all sounds like homework to actually LEARN LabVIEW. You surely noted the Getting Started section on top of the LabVIEW forum, did you?

 

How do I implement all of this in LabVIEW?

Let's start:

 

The idea is to fetch the date and time a file was created

File/DirectoryInfo gives you the "last changed timestamp"…

(To get the file creation date requires the use of some Windows woodoo - you can tackle this when all the rest is working as requested.)

 

then compare it to the current system date and time

Instead of comparison I would use a subtract function…

 

Required output is the number of months, days and time that elapsed since the file was created.

To get time and date from interval in seconds is simple math. There are also functions in the Timing functions palette that will help you!

Please define "month" - I know 4 different definitions for "month" in the usually used calendar system…

 

If the file is more than six months old, an external application (.exe) will be launched to create a new version of the file.

Some pseudocode:

IF day > 180 THEN SysExec(external app)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,977 Views)

Month = 30 days (Taking the average no. of days per month in a year, that's 30.417)

 

I have already started working on the first part of the code which is to fetch the file creation date/time and the current system date/time.

 

I have attached the partially coded solution. My current bottle neck is to come up with the math to actually compare the date and time figures.

 

Seems to me that you've been around LabVIEW for quite a while now. Care to share the actual LV solution you came up with?

0 Kudos
Message 3 of 6
(3,966 Views)

Hi FVallent,

 

My current bottle neck is to come up with the math to actually compare the date and time figures.

It starts to get REALLY easy once you calculate time intervals using LabVIEW timestamps!

 

I don't think you can just subtract the "month" from DateTimeRecord: what's the result when you subtract 01.04.2017 - 01.12.2016 (both in dd.mm.yyyy)?

 

Care to share the actual LV solution you came up with?

In this forum usually the OP starts to post some code (not just images of code) and then we can improve this code. When you attach your VI: I prefer them saved for LV2014…

I already named all the needed functions, so what's your problem with them?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(3,960 Views)

FVallent11 wrote:

I have attached the partially coded solution. My current bottle neck is to come up with the math to actually compare the date and time figures.


Use Bundle By Name to convert the cluster from the Windows call into the Date/Time Record and then use Date/Time Rec To Timestamp.  Now you will have two timestamps that you can just subtract.  You can then use the Timestamp To Date/Time Rec to extract the months, days, hours, etc.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(3,933 Views)

Got it all figured out.

 

Your ideas have been helpful.

 

I have two versions of the program now. One that uses the kernel dll to extract file attributes and the simpler but equally effective version suggested by GerdW.

 

Cheers!

0 Kudos
Message 6 of 6
(3,895 Views)