LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare times while ignoring the date

Solved!
Go to solution

I have this...

 

date.JPG

'In Range?' is always false no matter what the current time is. I'm guessing this is because the date is included in the compare function.

I need to compare these times and ignore the date. I cant seem to find a way around this. The times will be the same everyday and I'd like for them

to be constants.

 

Any help?

 

Thanks.

0 Kudos
Message 1 of 10
(4,053 Views)

Hi Wayne,

 

you should set the date of the comparing "constants" to match the date of the "current time":

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,043 Views)
Solution
Accepted by WayneS1324

Try formatting the date into a string that does not include the day (only the hours and minutes).

 

Time Compare.png

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

Message 3 of 10
(4,039 Views)

Found a small problem with my posted code, the inputs on the In Range and Coerce function need to be in the format HH:MM, not H:MM (7:15 should be formatted as 07:15)

 

Tim W.

Applications Engineering

National Instruments

http://www.ni.com/support 

0 Kudos
Message 4 of 10
(4,037 Views)

Thanks Gerd and Tim.

 

I would not have though of trying to compare strings that way. The inrange and coerce knows its a time?

 

 

0 Kudos
Message 5 of 10
(4,033 Views)

Hi Wayne,

 

InRange will check strings only by usual character order, thus you need to format the hour as 2-digit number...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(4,027 Views)
Message 7 of 10
(2,974 Views)

Hi Chris,

 

what about this:

Seems simpler than to convert to a cluster, unbundle some data and applying more math to them…

Best regards,
GerdW


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

That won't work if you aren't in GMT and you are trying to compare times of day.

 

Let's say it is currently 11 pm.  I want to see if it is after 6pm.  I'm in eastern daylight savings time.

 

6pm today would give me a value that is higher (thus later) than 11 pm.

 

 

Luckily LabVIEW has this nice feature called subVI's that can hide the ugly parts of Chris's method and lets you reuse it.  😜

 

 

Message 9 of 10
(2,939 Views)

@RavensFan wrote:

That won't work if you aren't in GMT and you are trying to compare times of day.


That's why time zones and Daylight Savings Time should be banned and everybody just uses UTC.


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 10 of 10
(2,930 Views)