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: 

string to datetime interesting problem

Solved!
Go to solution

Hello,

 

I am solving some issue with Labview and I find quite interesting bug.

 

It is just time conversation from string to datetime format.

In the picture below I made 24 times this conversation to show, what the result is for each hour of the day.

It looks like labview have some problem with conversation times in format 2:XX:XX (I mean, when number 2 is the first).

 

Has anyone any idea, how to solve that bug?

0 Kudos
Message 1 of 11
(3,674 Views)

Hi vasicek,

 

well, it appears to correlate with changing from "standard" time to daylight savings time (last Sunday in March & October for great parts of Europe)…

 

Remember: the timestamp indicator will always (or: by default) adapt to your local OS timezone settings!

Best regards,
GerdW


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

Thanks for your reply!

 

I think that you are right, it is a time change, but is there any possibility to avoid that thing? I mean, I wanna use "the missing hour" in my code, is it possible?

 

Thanks!

0 Kudos
Message 3 of 11
(3,629 Views)

The problem is the hour isn't really "missing".  It never exists.

 

So what do you mean by using the "missing" hour?  You might need to modify your code to account for that.  Or you might want to modify your code so it outputs the values in terms of Greenwich Mean Time or Universal Time.

0 Kudos
Message 4 of 11
(3,618 Views)

That hour exists! in many countries for example...

 

My goal is get the same time in timestamp as I setted in string...even if the timechange is occur.

 

Thank you!

0 Kudos
Message 5 of 11
(3,603 Views)

@vasicekv wrote:

My goal is get the same time in timestamp as I setted in string...even if the timechange is occur.


Then you need to standardize on UTC time.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 11
(3,596 Views)

@vasicekv wrote:

That hour exists! in many countries for example...

 

My goal is get the same time in timestamp as I setted in string...even if the timechange is occur.

 

Thank you!


No.  It doesn't.  One day a year has 23 hours.  One day a year has 25 hours.   2:00-3:00 am hour  doesn't exist when clocks jump forward at 2am in the spring.  The 1:00-2:00 am hour exists twice when clocks jump back in the fall.

 

If you are in a country that doesn't have daylight savings time, then that would be reflected in your PC settings and the behavior of the missing hour or extra hour would not show up.

0 Kudos
Message 7 of 11
(3,584 Views)

Please, we should be focused on the problem.

The easiest explanation of my problem again: I have time string "29.3.2015 2:10:00.000" and I wanna convert it to timestamp with the same time, but the result is now one hour lower because of timechange.

Is there some easy way, how to solve that? Should I change some settings somewhere?

 

Thanks for your reply!

0 Kudos
Message 8 of 11
(3,576 Views)

Hi vasicek,

 

you could set your computer to use UTC.

Or you can play with "Date/Time to Seconds" function and its LVDateTimeRec datatype…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(3,556 Views)
Solution
Accepted by topic author vasicekv

The solution is:

1.convert variant to string

2.string convert to variant with format string %^<%d.%m.%Y %H:%M:%S>T, where ^ is important

3.use Format Date/Time String.vi with UTC set to True

0 Kudos
Message 10 of 11
(3,456 Views)