LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Differnce in time while writing and reading time to a .txt file

Hi,

 

I have done a code to store date in a .txt file and then read from that txt file and output that date into a time stamp indicator. But the problem the input time and output time are not same. I dont know why. I have uploaded the code. Thanking You in advance. Diff input time and output time.PNG

 

 

0 Kudos
Message 1 of 9
(3,922 Views)

Your problem is that you use "%T" in your format string.  %T is absolute time which actually has the time first and then the date.  

 

You need to change that to use the correct time format that matches the way you save time.  I got your VI working when I replaced "%T" with "%<%m/%d/%y %I:%M:%S %p>T".  Look up the format codes for time format string for more details on what each part means.

 

Pulido Technologies LLC

0 Kudos
Message 2 of 9
(3,903 Views)

Could you please upload the working VI, which you got. 

0 Kudos
Message 3 of 9
(3,897 Views)

pulidotech wrote: I got your VI working when I replaced "%T" with "%<%m/%d/%y %I:%M:%S %p>T".

The Format Date/Time String defaults to "%c".  Therefore the Scan From String should have the format of "%<%c>T" to match.

 

However, %c uses the system format.  This is generally a bad idea.  If I tried to read the same string on my machine, it would fail.  So the format should be explicit on the Format Date/Time String and the Scan From String to make it consistant on all systems.


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 9
(3,884 Views)

Thank You very much. I got it. I got it using %<%c>T. So when u said the format should be explicit on the Format Date/Time String and the Scan From String to make it consistant on all systems, I didnt understand. What does it mean.Which format should I use. Thanking You.

0 Kudos
Message 6 of 9
(3,864 Views)

What he's referring is that when your formats should be explicit in both the write and read steps.  Look at the image for an example on a consistent/explicit %c format.

 

Pulido Technologies LLC

0 Kudos
Message 7 of 9
(3,857 Views)

Thank u got it

0 Kudos
Message 8 of 9
(3,849 Views)

@pulidotech wrote:

What he's referring is that when your formats should be explicit in both the write and read steps.


Actually, I meant something more like this


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
0 Kudos
Message 9 of 9
(3,837 Views)