LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to fix date to correct form

Solved!
Go to solution

I am getting the date from a CSV file which outputs the date in DD/MM/YYYY so it would be for example 06/05/2017 which is not the default that windows uses because windows shows a date format of 6/5/2017. I fixed this issue in Labview by having it search for the '0' and replace it with nothing using Search and Replace. I have two of these Search and Replace to get the 1st two zeros but not the last one. Now I am having the issue that the second '0' sometimes deletes the '0' in 2017 when the date becomes 06/15/2017. How can I make use of Search and Replace to just search for characters 3-5 or to make it stop before deleting the '0' in 2017. 

 

I cannot change the date format from the CSV file because my program gets that data from a GUI and wish not to change the CSV.

0 Kudos
Message 1 of 3
(2,649 Views)
Solution
Accepted by topic author sportsguy99

Hi guy99,

 

use ScanFromString with format "%d/%d/%d", then wire the 3 resulting integers to FormatIntoString using the very same format string!

check.png

This will remove leading zeros…

 

What's wrong with dates shown including those leading zeros?

Best regards,
GerdW


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

Here is the part of the code I am taking about. A little confused on what your saying. As you can see, I had in a array and concatenate string for single string. Then it has the 06/15/2017 and i delete one string and the second one deletes the other '0' but in 2017. Dont mind the deletion of the " as I need that for a different reason. Why would I implement your solution into my code. I am a little confused. I want it to somehow not look into the 2017 ever. 

0 Kudos
Message 3 of 3
(2,636 Views)