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: 

GetDate/ format date time string

Solved!
Go to solution

Hello everyone,

I needed some help figuring why i can't use %p to denote A.M and P.M on my outut screen. When i run the application i get the time but not the denote am/pm.

I've attached both the image and the VI.

Download All
0 Kudos
Message 1 of 7
(5,393 Views)
Solution
Accepted by topic author JÞB

The 12 hour clock used %I for the hour.

 

The correct format string is %I:%M:%S %p

Message 2 of 7
(5,371 Views)

Use % I instead of %H, %H is for 24h clock.

 

Ben64

Message 3 of 7
(5,370 Views)

Refer to this forum post for the answer:

 

http://forums.ni.com/t5/LabVIEW/Using-Format-Date-Time-String-Function-Vi/td-p/1581082

 

 

In short, replace the %H with %I to go from 24 hour format to 12-hour format.

0 Kudos
Message 4 of 7
(5,368 Views)

Thanks alot!

0 Kudos
Message 5 of 7
(5,362 Views)

Thanks alot!

Since i was testing in the morning i never saw anything passed 12 P.M

0 Kudos
Message 6 of 7
(5,358 Views)

Have one on me Bill!

Capture.PNG

Bad format strings can be a pain.  You simply cannot use "H" and expect a "%p" to make any difference!  "%H" denotes a 24hour clock where AM and PM are meaningless  and capitolization is important to format strings. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 7
(5,327 Views)