LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Date/Time String equivalent in NXG

I have a Vi on LV 2017 that uses the regular Get Date/Time String vi that receives an integer.

 

I couldn't find the equivalent on LabVIEW NXG, there are several choices but not of them output the right string that LV 2017 outputs

 

 

CLAD, CTD
0 Kudos
Message 1 of 10
(3,362 Views)

Is there something corrupt in your LabVIEW installation?

 

On mine, that isn't an integer, but a timestamp.

 

 Capture

EDIT:  Perhaps nothing is corrupt in your LabVIEW installation.  That might be a polymorphic function.  When I wired an integer into that same terminal, it connected without a coercion dot and the context help changed to look like you have it with a blue wire going in.

 

I have not touched NXG at all.  But have you tried to wire in your integer into the function it provides?  At the end of the day, the function is looking for a number that represents seconds since the epoch.  If your integer can't wire directly to the existing function without error, perhaps you can adapt the date from an integer to whatever the function will take?

0 Kudos
Message 2 of 10
(3,334 Views)

It looks like 'Get Date and Time String' in NXG doesn't have a polymorphic 'timestamp' input like it does in LabVIEW. So you'll need to insert a 'To Timestamp' function in NXG to get the same behavior:

ng.png

Message 3 of 10
(3,323 Views)

I will try that tomorrow...

 

I remember i tried that but it was an interger, not a double... 

 

Going to double check tomorrow....

 

 

CLAD, CTD
0 Kudos
Message 4 of 10
(3,297 Views)

Did not work...

 

Look at the picture...

 

 

CLAD, CTD
0 Kudos
Message 5 of 10
(3,274 Views)

Help for Get Date/Time String (LabVIEW2015):

"time stamp can be a timestamp or a numeric. If numeric, this number is the time-zone-independent number of seconds that have elapsed since 12:00 a.m., Friday, January 1, 1904, Universal Time [01-01-1904 00:00:00]. The default is the current date and time. If year is before 1904, time stamp is negative."

 

This is no solution to your problem but, I would say LabVIEW2017 is doing something wrong with the negative number and NXG returns a more logic result. -703196896 seconds are a bit more than 22 years before 1904.

Edit: Sorry, the result from Get Date/Time String is not logic at all (12/31/1903). I confused with date time record.

0 Kudos
Message 6 of 10
(3,262 Views)

Hi,

 

the problem is with just that specific function:

check.png

(image taken from LV2011)

I do prefer FormatIntoString most of the time (for any kind of string handling)…

Best regards,
GerdW


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

So did i find a bug or what?

CLAD, CTD
0 Kudos
Message 8 of 10
(3,245 Views)

There’s definitely a difference in behavior, but I hesitate to call it a bug, since sending a negative integer into a time stamp parameter doesn’t appear to me to have defined behavior. 

0 Kudos
Message 9 of 10
(3,226 Views)

I think it is more than an inconsistency.   Possibly a bug on the integer version of Get Date/Time String in traditional LabVIEW.  (See the attached snippet.)

 

There is a defined behavior for negative values in timestamps.  It is that they reflect the number of seconds BEFORE the epoch.  The NXG version of Date/Time record is handling that.  The NXG version of Get Date/Time String seems to be coercing it to 0, and thus the epoch.

 

Classic LabVIEW with a negative value going into a timestamp indicator is giving the same date time as the NXG date/time record.  But the negative value going into Get Date/Time string is being typecast into a U32 then that being given out a string.  (So 2's complement of -703196896 is 3591770400.)   There is no coercion dot happening on that input indicating that anything different is happening.

 

I have a question for the original poster:

Why are you dealing with negative integers in your timestamp values?  It is not impossible, but very unlikely you'd be doing anything with timestamps for the 1880's.

Does the date Oct. 25, 2017 mean something in your data more so than  Sept. 17, 1881?  I bet, without seeing your code, that you have an issue with your data types upstream.  If you fix that, the issue with your timestamps in the Get Date/Time String will resolve itself.

 

 

 Example_VI

 

0 Kudos
Message 10 of 10
(3,218 Views)