Formatdatetime


CH2014

Recommended Posts

I have just noticed that if you use %W in a file name (i.e. %W is week number with Monday 1st Day of Week) The result is 1 out from the actual week number. I note from DAQ manual that the %W weeks are numbered from 00 - 53 so I can see why it is out by 1.

 

e.g. FormatDateTime("%W", Systime()) today gives a value 28 but the actual calendar week is 29.

 

Is there anyway of adjusting by 1 within a filename. At the moment I have a Export Logging File name which states this week is no 28.

Link to comment
Share on other sites

  • 2 weeks later...

Re-reading my post above. I don't think I explained very well. I shouldn't have mentioned FormatDateTime. I should have said: -

 

my export logging file name is called : -

 

C:\HMI_DATA\SensorsLevels_LOG\SensorLOG_WeekNo%W%b%y

 

So at the beginning of each week I end up with a new file called (for example)  

 

SensorLOG_WeekNo28Jul14     (this would be the file name in calender week 29)

 

I just want to know if it is possible to adjust the %W by 1 within the export logging file name. If not I suppose I will just have to adjust the file name to: -

 

C:\HMI_DATA\SensorsLevels_LOG\SensorLOG_FileNo%W%b%y

Link to comment
Share on other sites

You can't do it directly in the Export set name, but you can use the old method of setting the path from script, probably from an Event on one of your channels, or just in the line before you start the export set.  It'd be something like:

 

export.myExport.strFileName = "c:\HMI_Data\sensorsLevels_Log\SensorLog_WeekNo" + formatDateTime("%W", systime() + 86400*7) + formatDateTime("%b%y", systime())

 

What I did is split the two formatting functions.  I call the one with %W first, adding one week to the current time.  In the second one I use the time straight up.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.