From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1 occurred at scan from string

I am using "Scan from String" function for converting the date format in version 16 Eval.

 

My input string is "Wed, Sep 27, 2017".

 

I am expecting output as 27-09-2017.

 

But,  I am getting the error "Error 1 occurred at scan from string".

 

Snip Attached.

0 Kudos
Message 1 of 5
(2,652 Views)

Hi depme,

 

My input string is "Wed, Sep 27, 2017".

I am expecting output as 27-09-2017.

So you have an input string of (simplified) "text text numbercomma number".

Your format string tells ScanFromString to look for "numberminusnumberminusnumber".

 

Which result do you expect from such a format string with this input? (And why don't you implement some error handling?)

Best regards,
GerdW


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

Hi,

 

To have your expected value is not possible with only this function because we use "Scan from string" when we know the exact format of the input.

 

And the input "format string" of the function "scan form string" is not the format that you would expected to have but the format of the input string.And your error is because the "format string" don't matches with your input. change it in the correct form and the results will permit you to have your expected value

 

Regards,

Fred

 

Kudos are welcomeSmiley Wink

0 Kudos
Message 3 of 5
(2,609 Views)

Building on the 2 previous replies, the format string pattern needs to match the input string. And I think there is a misunderstanding of which data type you need the output to be (either timestamp or string). Here's a quick example that extracts the timestamp output and then converts it to a string in the format you've specified:

 

format timestamp.png

 

EDIT: Added timestamp conversion to string output

 

 

 

dK
0 Kudos
Message 4 of 5
(2,604 Views)

Thanks for the solution.

 

I was expecting output timestamp as string only.

0 Kudos
Message 5 of 5
(2,573 Views)