06-19-2019 07:18 AM
So Im using Scan from string with this pattern " %<%d.%m.%Y>T " to get a time stamp from a string like "30.05.2019".
The problem is that I get 30.05.2016 1:00:00 as time stamp instead of 30.05.2016 0:00:00. This has caused so many bugs in my program any idea how to fix it?
Thanks
Solved! Go to Solution.
06-19-2019 07:38 AM
06-19-2019 07:46 AM
I'll look into it thanks. Otherwise I found another solution just add 00:00:00 to the string.
06-19-2019 07:55 AM
06-19-2019 08:07 AM
Yep here you go
06-19-2019 08:51 AM
When I run your code (in the US), I get a two-line string with the first line "12:00:00.000AM" and the second line "6/5/2015" (the US default order is month, day, year). By changing the indicator (output 1) Display Format (Advanced Editing Mode) to "%<%x>T", this gives a 1-line output of "6/5/2015", which seems to be what you might want.
Bob Schor
06-19-2019 09:01 AM
The question is what do you do with that timestamp value once you've created it from the string?
Timestamps are significant in that they both contain a date and a time value in it. Yet some times in programming, you really only want one or the other. Like in this case, you have a date, but your original input has no time information associated with it. So what do you want the time to be? MIdnight UTC? Midnight your local timezone? Some other time of day? You just don't care what it is? For instance, you might just want to know if a particular value matches a particular date on the calendar.
Other times you may not care about the date, only the time. You want to compare something to 9am, no matter what the date. For example, is the current time before 9am or after 9am? You might always be assuming the current date, or some date in the past or future. But a timestamp of 9am to compare to has a specific date assigned to it.
So what do you do in either of these situations? You need to manipulate the timestamp value. Either give assign a specific date you don't have in your original information. Or assign a specific time. Look at the other functions in the Time palette. There are ones that work with clusters called time records. There you can assign specific values of dates such as months, days, years, or hours, minutes, seconds, to create timestamps where you can fill in the missing data elements to create a specific date/time timestamp value..
06-19-2019 09:16 AM
Im using the 24 Hour system.
I have 3 inputs in the program. a time variable and 2 time constants.
The program is quite simply if the time variable is between those 2 constants then I get true as a boolean. I have for example 5.3.2015 00:30 (or 3.5.2015 if you're from america). if its between 4.3 and 6.3 then I get true. the problem I had is that I always got 4.3.2015 1:00:00 when converting the date instead of 4.3.2015 0:00:00 which led to some nasty errors. the method I used worked. but still I was still curious how to fix this problem without using any shenanigans
06-19-2019 09:39 AM
What I'm saying doesn't matter whether you are using a 24 clock or a 12 hour am/pm clock.
I'm just describing how it can be challenging to work with LabVIEW timestamps which have a date and time of day component, whether you show them or not.
So there always will be some sort of shenanigans to fill in and standardize the missing parameters for the timestamp. I think defining a midnight time in your string to go with your date string is as good of a method as any.
06-19-2019 10:12 AM
When I see an "off-by-one-hour" situation, I think about Daylight Savings Time, which (in the US, in June) subtracts an hour from the UTC-TimeZone-adjusted time. Here's a Snippet that shows the current Date/Time in the eastern US, and another routine that takes the Time Stamp, converts it to display just the date (in whatever format you've set as your PC standard, d/m/y or m/d/y) using Format into String, then isolates Day, Month, and Year using Scan from String. Very simple.
Bob Schor