03-24-2017 11:12 AM
Hello,
I have a VI that converts a time string to a time stamp. The AM and PM flags get reversed when I do the conversion.
Any ideas on why this occurs?
Thanks
Solved! Go to Solution.
03-24-2017 11:22 AM
Try to make current control values default before saving so we have something to play with and we know what you are entering
03-24-2017 11:28 AM - edited 03-24-2017 11:29 AM
03-24-2017 11:55 AM
Thanks. You probably set the default value for the array element instead of for the array.
Yes I see the flip but I am not familiar enough with timestamps trying to decide what, if anything, is the problem.. (see also this discussion for other time curiosities :D)
03-24-2017 12:13 PM - edited 03-24-2017 12:23 PM
Interestingly, the two elements without the time component alternate time values on each iteration.
First:
Second:
EDIT: Found it here
Don't use %H, which is 24 hour format. Use %I
03-24-2017 12:39 PM - edited 03-24-2017 12:41 PM
Mancho, That is something extra odd on yours. I'm looking at it in LV 2016f2, and both of my last two elements show it as 7 am.
ASTDan, Altenbach brought up a good recent thread. Pay particular attention to my last message in that thread. https://forums.ni.com/t5/LabVIEW/UTC-0-001-seconds/m-p/3598948#M1008490 where I linked to two older threads, that both seem to apply in your case.
1. When using the %p flag for AM/PM, you should NOT be using the %H flag. It should be %I (eye) for a 12 hour clock. Put in %I, it fixes the first two elements. (However, it also gives default dates/times on the last two elements)
2. You have automatic error handling turned off for your VI. Why? Turn that back on. I needed to do that to figure out why the last elements stopped giving data. It then showed an error 1 because of the invalid scan from string. And that makes sense because you are asking for scanning a string that has date and time values in it, but those last two only contain date values.
The first thread I linked was primarily talking about the results between %y (2 digit year) and %Y (4-digit year) and behavior that changed depending on if the incoming string had 2 digits or 4 digits. Though we aren't talking about years here, it seems like somewhat the same effects in terms on how strict the function applies the rules for scanning the string. The second thread is the one that dove into the %I vs. %H for the hour code.
03-24-2017 01:23 PM
RavensFan, it is odd, but I'm not going to concern myself with it, since, as you pointed out, scan from string is producing errors for those, as it should.
03-24-2017 02:59 PM
Correction: I do NOT get an error using 24-hour format (%H), but since I reopened the file, I don't get the alternating times. I really would expect to get the same error on formatting regardless of hour format.