cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Comparing current date time with file creation date and time

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
(479 Views)

Re: Comparing current date time with file creation date and time

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
CLAD, using 2009SP1 + LV2011SP1 + LV2017 on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 2 of 6
(462 Views)

Re: Comparing current date time with file creation date and time

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
(451 Views)
Highlighted

Re: Comparing current date time with file creation date and time

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
CLAD, using 2009SP1 + LV2011SP1 + LV2017 on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 6
(445 Views)

Re: Comparing current date time with file creation date and time


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.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
Message 5 of 6
(418 Views)

Re: Comparing current date time with file creation date and time

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
(380 Views)