LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File a week old? Stop adding to it. Comparing 2 dates.

I'm creating a file with the date it was first created and I'm adding to it more info everytime my vi is called. I want to stop adding if the file is older than 7 days, any idea how to approach this?

 

I tried using time stamps but I couldnt get to the index of the day.

 

Thanks.

0 Kudos
Message 1 of 13
(2,849 Views)

Subtract the current date/time from the file date/time timestamp.  When the value is greater than 7x86,400  (7 days x seconds in a day), then 7 days have passed.

Message 2 of 13
(2,829 Views)

I came up with two ways, I attached one to turn a boolean on every Monday, which in turn can obviously be used to start a new measurement file. However, in the expressVI write to measurement file you can specify to save to a series of files. There are probably other ways to do it as well using the by scanning a time date string, but these seem to be the two easiest that come to mind.

 

-Franklin

Message 3 of 13
(2,828 Views)
Could you dynamically compose the filename based on the weeknumber in stead of date? The filename would then automatically change every 7 days, when you enter a new week.
0 Kudos
Message 4 of 13
(2,819 Views)

Here are a couple of methods you could use.  For similar purposes I usually normalize all times to start at midnight, so I have a simple subVI that gives me the timestamp for midnight of the date in a timestamp.  Then you can subtract timestamps and convert seconds to days easily.  The snippet shows two methods:  Find difference between midnight of two entered timestamps, or simply find the difference in days between two timestamps (this method likely starts new files in the middle of the day).  I use the former and if it is greater than six days, time for a new file.  (I usually like to start new files daily, typically at midnight).

 

OneWeek.png

 

 

 

 

Message 5 of 13
(2,817 Views)

thanks guys, would you be so kind and downconvert the VI and the snippet for me?

 

thanks,

peter

0 Kudos
Message 6 of 13
(2,791 Views)

what if you were to start saving the data each saturday at midnight and finish next saturday at midnight?

0 Kudos
Message 7 of 13
(2,768 Views)

@spaaw wrote:

what if you were to start saving the data each saturday at midnight and finish next saturday at midnight?



Easy as pie! 

 If its Saturday see

          if a file exists with todays date in the filename. 

               write to it

          else create it write to it,

Else (Not Saturday) write latest file


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 13
(2,765 Views)

thanks for the quick replay!

 

here is a more detailed description on what I want to achieve:

 

I will be creating an excel spreadsheet with data. There will be 1 excel spreadsheet for each week of the month (starting Sat at Midnight and finishing saving data after 168 hours on the next Sat at Midnight). Data will be added to the spreadsheet throughout Sat - Sat. Now, lets assume the first spreadsheet file created will happen on Thursday.. how can I tell it to stop saving on Saturday at Midnight and start saving new data to a new, fresh excel spreadsheet?

 

so basically:

VERY FIRST Data write to the spreadsheet =true?

Create spreadsheet at current time.

 

ADDITIONAL Data write to the spreadsheet:
See if that file is within SAT-SAT
If it is, keep adding data to it.
If its not, create new spreadsheet.

 

 

My issue is that I do not have a constant here. The first spreadsheet could be created on any day of the week.. If i had a constant i could just see if a week has passed from its creation..

 

I will be working on it and I will keep you updated if i find a solution.

 

Any help is appreciated!

 

thanks
 

0 Kudos
Message 9 of 13
(2,754 Views)

@spaaw wrote:

thanks for the quick replay!

 

here is a more detailed description on what I want to achieve:

  

My issue is that I do not have a constant here. The first spreadsheet could be created on any day of the week.. If i had a constant i could just see if a week has passed from its creation..

 

I will be working on it and I will keep you updated if i find a solution.

 

Any help is appreciated!

 

thanks
 


so. expanding on the example from previous.

 

if it is not saturday use the latest file if it was created this month or create a new one


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 13
(2,746 Views)