Timestamp scan from string

Hi All,
A minor query about time stamps and scan from string. I needed to convert a string back to a timestamp and found the solution I needed at this post: Link
I wanted to make it a little more programatic and noticed that when I assembled the formatting string it would not recognise the assembled output as a Timestamp - it outputted a double. The strings inputs are identical. The double precision output converted to a Timestamp to give the correct value - so I have a work around.
I was just curious if this is a minor issue with LabVIEW or is this an intentional feature? Or is there some step I'm missing to coerce my output to a Timestamp.
Thanks,
Dave
Solved!
Go to Solution.

I convert a string to a double represented as a timestamp. The strange is that it converts wrong, if I wire a 'NaN' to the default value. Look inside the code..
(LabVIEW 2010 SP1)
Attachments:
Untitled 1.vi ‏10 KB

Similar Messages

  • "scan from string" to timestamp doesn't work for 18:00:00 (6PM)

    I just found a strange issue in LabVIEW.  I hope I'm doing something silly, but I just may have found an unusual bug.
    run the snippet below with the following for the input string: 03:00:00,18:00:00,17:00:00
    Time converts fine for just about any other time EXCEPT 18:00:00 (6 PM) for which it is returned as 00:00:00 (midnight). If you even add a second to it (18:00:01) you get back the expected result.
    Here's hoping I'm not loosing my mind
    Matt Holt
    Certified LabVIEW Architect
    Solved!
    Go to Solution.
    Attachments:
    TimeParseBug.vi ‏11 KB

    As annoying as it may seem, this exact scenario is an abuse of the timestamp. A timestamp is meant to be used for absolute times. And that includes a date. As Ravens Fan already pointed out, the 0 seconds since January 1, 1904 GMT is used in all timestamp display routines to mean the canonical invalid timestamp and hence the timestamp control displays the default string indicating the actual date/time format rather than a specific date/time.
    If you need an absolute timestamp, for instance because you do want to have a local time indication, although the date is not relevant, adding an offset of 86400 to all values would fix it once and for all. Now the timezone offset can't cause the timestamp to reach 0 ever, even if you reside west of GMT, and it will be fine (until you start to do timestamp arithmetic that involves subtraction of relative timespans, then you would have to make the offset big enough that this will never get an issue). The current date would serve as a nice offset for that, which would be MattH's last suggestion. Nice to see that the Scan from String routine actually does use the passed in timestamp as default value and only replaces the values it is configured to parse.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Strange "Scan From String" to Timestamp Error

    hi,
    i am trying to parse my time-string into a Time Stamp with "Scan From String" but i get some strange Error(1).
    The Code:
    The Error:
    can anyone confirm? do i have an error in my parser-string?
    is it possibly related to this Bug
    461196
    Scan From String VI returns Error 1 with "%t" as the format string input
    http://www.ni.com/product-documentation/52151/en/
    that should be fixed?
    my labview version is
    LV 2014 Service Pack 1 -- Version 14.0.1 (32bit)
    with the RealTime addon (but the code in question was not run on RT)
    thanks for your time.
    Solved!
    Go to Solution.

    Why do you have the square brackets around the scan from string format string? They are not there when you generate the timestamp string so it will fail when trying to convert it back as they are expected to be there.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Scan from string to timestamp not working

    Hi,
    I have a problem with the "Scan from string".
    The format string "%<%H:%M:%S%ds%bs%y>T"
    works for the input string "11:12:1322sJans2010"
    but doesn't work for the input string "11:12:1322sFebs2010"
    The only difference is the month (Jan or Feb). I got know idea why!
    Could anyone help me?
    Regards,
    Marcelo
    Attachments:
    dateString.vi ‏6 KB
    date.PNG ‏5 KB

    Both work for me in LabVIEW 2009; perhaps this was a bug in 8.6 that's been fixed?
    Also, is it possible your operating system is running a different language, in which Jan is the abbreviated form of January but February is something else?

  • Scan From String White Space

    i all,
    I'm trying to use Scan From String in order to parse some data coming in from UDP. 
    Input String: ASCII [00 01 02 03 ... FF]
    What I want: s[00 .. 30]  d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    ATTEMPT1
    Format String: %49s%2d%2d%2d
    What I get: s[00-09] RUNTIME ERROR!
    ATTEMPT2
    Format String: %49[^]%2d%2d%2d
    What I get: Only allows first output. Will error out if I use any additional outputs from Scan From String
    ATTEMPT3
    Format String: %49[^(0xFF)]%2d%2d%2d Value in () is ASCII character FF.
    What I get: s[00 .. 30] d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    It appears as though when I use %##[^] it thinks I'm looking for the ENTIRE string so it will not let me add any more Formatting.  If I add a delimiter other than ^ it will run, and it will work presuming that character isn't within the first 49 characters... and I can't guarentee that it won't.
    I'm aware I can parse my string using subsets and whatnot... but Scan From String is so elegant.  It would be great if %S allowed for white space... or if $##[^] would simply take the first ## characters and allow me to Format after that.
    Is there a simple, elegant way to do this?  I wish my dataset was only 3-4 outputs. It'd be ideal if I could.  Thanks.
    Edit:
    It might be more helpful if I provide a less abstract example:
    I have an ASCII Header (Finite Length String), a Sender IP (Finite Length String), a Timestamp, a Message ID (Finite Length Decimal), A Message in ASCII ( '1' actually means 0x31, not 0x01)  And for some ungodly reason... no delimiters.
    So I was HOPING %##s%##s%<%H:%M:%s>t%##d   (With leftover string to be my message)  would work, but if any white space is contained within there... it messes up. 

    I cannot provide exact strings because the string is actually ASCII characters, most of which aren't displayable. 
    I have a string where I have:
    24 ASCII Characters representing 6x U32 Header Data
    13 ASCII characters represening the sender IP (string)
    12 ASCII Characters representing the name of the message (String)
    12 ASCII Characters representing 3x U32 Data
    12 ASCII Characters represneting the name of packet (String)
    12 ASCII Characters representing 12x U8 Data
    256 ASCII Characters represening 256x U8 Data
    etc...
    It would be ideal to simply Scan from the string and output the data with the appropriate data types already assigned instead of splitting string and type casting each individualy.  But if, for example, my header starts with an ASCII representation of a U32 of 2560(decimal) it would look like this:  [00][00][0A][00].  ASCII 0A is considered white space.  So my header would only contain 2 ASCII characters instead of the desired 24.

  • Day of year bug - format date/time string and scan from string?

    I've noticed that the day of year returned by "Format Date/Time String.vi" starts with a value of 1 for Jan-1 while "Scan from String.vi" wants a 0 index.  Is this a bug or feature?  
    (I'm using Labview 2010 Service Pack 1)

    I think the best idea is to use seconds since for your arithmetic, because it is going to be the most consistent and robust solution. Knowing that a day has 86400 seconds is all that is needed and you won't run in possible inconsistencies with date time implementations caused by our anything but logic calender. I would hazard that the functionality of converting a timestamp into year and day of year and back is impossible to make consistent without sacrificing other possibly conflicting transformation in the Timestamp into String and Timestamp from String manipulations.
    "Seconds since" being the actual base unit in all LabVIEW timestamps, it is best to do any arithmetic on it in this base unit.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Scan from string error 85

    Hi Everybody,
    I'm trying to use LabView to
    process some data.  The data, although it was collected via labview,
    has been written out to csv file format.  I have been able to
    successfully open the file and use the search split string function to
    remove the "header" from the data stream.  Now I'm trying to parse the
    header to extract some pieces of the info that is there.  I'm trying to
    do this with the Scan from String VI.  
    So
    far I've been able to retrieve the Specimen ID from the first line of
    the header by setting the format string input of Scan from String as
    "Specimen ID ,%s", which works just fine.  Problem is, when I
    adjust
    the format string to include the next piece of data I want, I
    inevitably get an Error 85, which is a failed scan.  In fact, I
    get an err85 every time I try to extract something from after the
    second line.  I've attached a VI in which I cut and pasted an
    example header string in as a string constant and an example of how I'm
    trying to extract the values.  I've tried playing around with
    spaces and different formats, but get the err85 no matter what I do
    (unless I extract the first line).  I have a hunch that it has
    something to do with the EOL marker, but no idea how to work around it.
    A search of posts here show that a lot of people have issues with the
    scan from string vi, but nobody I could find had this exact
    problem.  I've also considered using the spreadsheet spring to
    array function, but because I have a mix of commas and EOLs it doesn't
    seem to work either. HELP! I really don't want to have to write this
    over in VBA/Excel.
    Thanks,
    Turk
    Message Edited by YoungTurk on 07-29-2005 10:36 AM
    Attachments:
    Scan.vi ‏12 KB

    You should probably parse it line by line (See attached, LabVIEW 7.1)..
    The attached example shows one possibility to get all the Items and values out. Not all values are strictly numeric so you would need to adapt the code a little bit. (This is just a very rough 1 minute draft).
    You might want to cosider to extract all values into a cluster for further processing, Have a look at the example  posted in this thread . It can be easily adapted to read the values in the proper format (DBL, I32, Date, String, etc.) depending on the item name.
    Good luck!
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ScanMOD.vi ‏30 KB

  • Wrong use of "Scan From String" function in a while loop?

    Hi,
    I've got a "Scan From String" function inside a while loop. On the first iteration it converts correctly the number passed by the input string (for example 4) But on the second one it has only spaces (one or more \s) as input string.
    I expected to obtain a zero as output (as it does always that it can not make any conversions, as I am supposed to) but indeed, i subtracts 1 from the previous number (according to the number indicated as example I would obtain a 3 as output)
    What's wrong with this?
    Does the function fails on this case?
    The rest of the diagram o the VI is expected to manage a 0 on that situation, like others in which the conversion is not made.
    Andres.

    I have simplified the VI evading calls to other VIs and trying to reproduce the mistake.
    The type of string I introduce to reproduce the mistake is:
    clock 3 (30) clock (40)
    Forgetting to introduce a number between the second "clock" and the following parenthesis, I would manage it programmatically with code that isn't included.
    Then "Scan From String" is supposed to do not make a conversion. But it leaves a 2 as output (in this example)
    I have realised, unbelievable but true, that it has matter with the number I substract to the output number (if it were 2, I would obtain 1 as output and so on)
    Excluding that, I got the conversion made before as output, 3, on the second time that "Scan From String" executes. But, how can this func
    tion as bad?
    I am using LV4 on an old PC. I have tried to reproduce it with LV6 and it works. But it isn't desirable for me, I would have to convert a lot of VIs and surely I will find a lot of errors due to the conversion (I have already tried)
    Attachments:
    EXTCLOCK.VI ‏26 KB

  • Using scan from string to convert a string into a number

    I wanted to use scan from string to change a string into a decimal number, but when the string is, for example, 9.14123E-2 it just returns 10. How can I get it to return .00914 or 9.14E-2(as a number not a string). Would there be something easier than scan from string? I'm using labview 5.1. Thank you!

    Hello,
    May be you can checkout the attached example.
    Perkash Mohan Lal
    Institute of Semiconductor Technology
    Technical University Braunschweig
    Attachments:
    string_conversion_1.vi ‏44 KB

  • Error 1 occurred at Scan From String (arg 1)

    I am communicating with the AT Trainer 5000 via serial port to USB converter.
    I installed all drivers of converter successfully and it is shown in MAX as com port. I also installed VISA software. 
    I am using labview 2013 version.
    When I connect the hardware to PC via usb to serial converter, try to run the program for seeing of real time graphs, I am receiving this error Error 1 occurred at Scan From String (arg 1) whereas there is no waveform shown in waveform chart. 
    Also read buffer didn't show an incoming data at read buffer.
    Other details for this error is
    Possible reason(s):
    LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
    Also pics of error is:
    Program is also attached. Please checked the also.
    Expert please help me how to get rid of this error.
    Attachments:
    Project.vi ‏23 KB

    Since you are using the termination character, you should not use the Bytes At Port property node.  Just set the number of bytes to read for the VISA Read to something really high (larger than what you expect in a single transmission).  The VISA Read will stop reading once the termination character is reached.
    Now, what is the format of the data coming from the instrument?  I see you are converting an ASCII Hex string into a number while trying to also turn it into a double.  That is likely why you are getting your error.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • How do I avoid Error 85 in Scan From String scanning VISA read buffer?

    I have encountered an Error 85 with my Scan From String VI. I have a timed
    loop to read data from a device (flowmeter) using a serial port. This device takes
    periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
    between measurements may vary, so I decided a timed loop would be better than a while loop.
    The VI begins with VISA Configure Serial Port and then
    goes to a VISA Write which sends the message to the device to begin
    taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
    am taking the read buffer two places.
    First, I am taking it to an Array to Spreadsheet String with the
    Format String %.3f, as was in the Write to Text File example. Then I am
    using Concatenate Strings with this string and also a string containing
    the System Time. This string goes to Write to Text File, which I have
    configured using Open/Create/Replace File outside of the loop.
    Second, I am taking the read buffer to a waveform chart. I thought
    it would be a good idea to use Scan From String to convert the string
    into a DBL which I am then sending to the waveform
    chart.
    I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
    Also the format string for my Scan From String is %.3f
    I am getting the Error 85 at the Scan From String only sometimes.
    When this happens, there is no data being written to the text file. But
    other times, I get data and it writes to the text file just fine (but
    rounds to nearest whole number).
    Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.

    Is this what you mean? Did I wire the shift registers correctly?
    I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
    Message Edited by YeungJohn on 11-20-2008 03:48 PM
    Message Edited by YeungJohn on 11-20-2008 03:49 PM
    Attachments:
    SerialShiftVI.JPG ‏87 KB

  • Scan from string in pda

    Hello. 
    I work with LV 7.1, with the I Modul of PDA. 
    It doesn't work me 'Scan From String'. I have not found any contradiction because the pda doesn't accept it. 
    Does somebody know which the cause can be? As I can substitute it? 
    Thank you. 
    Greta
    Attachments:
    scan from string.JPG ‏6 KB

    Hello Greta
    The Scan from string function is supported in LV PDA but with some restrictions. The help file for LV PDA tells us:
    'The Format Into String function and the Scan From String function do not support changing the numeric separator (such as %#;). The Scan From String function does not support wildcard matches.'
    You are changing the numeric separator and this is not supported.
    Hope this helps
    BelenS

  • Scan from string and extract string between delimiter

    Hello,
    Basic questions.  Is it possible with the scan from string regular expression to extract the string that are within the specified delimiters.  Here is an example:
    \\Name of folder 1\Name of folder 2\Name of folder 3\File Name
    Can the scan from string output the following by specifying the right regular expression:
    Name of folder 1
    Name of folder 2
    Name of folder 3
    File Name
    I have tried \\\\%s\\%s\\%s\\%s but the %s stops at the first white space.
    Thanks,
    Michel
    Solved!
    Go to Solution.

    RavensFan suggested the appropriate function for your requirement, however you can also use an alternative, which is 'Spreadsheet String To Array'.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • Scan from string to Bundle by name

    I would like to take the output of "Scan From String and feed it into a Bundle by Name. There is no pre-existing bundle so I wonder if I can use a Cluster constant for the Input cluster. If so how is the cluster constant defined.
    My goal is to read strings from ini file sections, split out names and limits and put them into a cluster or array of clusters that can be stored as TestStand Locals or FileGlobals.
    Thanx,
    jvh 
    Solved!
    Go to Solution.

    jvh75021 wrote:
    There is no pre-existing bundle so I wonder if I can use a Cluster constant for the Input cluster. If so how is the cluster constant defined.
    This is a very common thing to do upon initialization - bundle things up into a cluster and carry it around to use throughout the program, in sub-vi's, etc. I'm glad you're not just throwing them all into locals or globals!
    Yep, you'll just use a Cluster constant into the Bundle the first time it's bundled. To make that initial cluster constant, take your known output cluster just create > constant. So to answer your question, the cluster constant is defined by the known output.
    However, if this cluster ever changes during development, and it will , you'll be changing every single cluster inside sub-vi's and that initial constant... or.. you'll follow Ben's advise and make a TypeDef!
    Message Edited by Broken Arrow on 04-09-2010 03:22 PM
    Richard

  • Scan from string with %g - result not accurate

    I am trying to use the "Scan from String" VI to convert a string into a number.  I am using "%g" as the format specifier.  The conversion is only grabbing the first six significant digits, yet I need it grab all significant digits.  Is there a real limitation here?  What could I do to solve this issue?
    I have attached a simple VI to demonstrate what I'm seeing.
    Thanks,
    Joel
    Attachments:
    Scan_from_String_Example.vi ‏7 KB

    It is because the display format for your numeric indicator is set for 6 significant digits.  Adjust the display format for the indicator and you will see that the other digits are there.

Maybe you are looking for

  • How do I use the DBMS_AQADM packages?????

    Hey everyone, Oracle noob needing help with creating and managing an Advanded Queue. Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 I have a user that was granted the roles of AQ_ADMINISTRATOR_ROLE and AQ_USER_ROLE. I am tr

  • "Illegal Sequence" message: GarageBand won't open, possibly due to corrupted files

    GarageBand recently crashed while trying to save a particularly long composition, around 200 bars long at the time, but it's been laggy since it exceeded around 60 bars. Recently, while saving the song, the app suddenly crashed. Now, whenever I open

  • Problem with photoshop elements 10

    when I go to my organizer it freezes up! I get a message that it is not responding.

  • How to display contents of update tasks more comfortable?

    Hello, periodically I send an information about failed update tasks (SM13) to our users, and I offer to send more details if necessary. Of course some users want to get more details, and then I go in SM13 through every single update tasks, every sing

  • T2000 Sever, Zones/Containers or LDOM's?

    I'm getting ready to deploy several T2000 servers. One requirement is Solaris 8, but Solaris 8 will not run on the T2000. I was planning on implementing Containers and install Solaris 8 in the Container. However, I was just told by a co-worker that C