LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Format Date/Time String Function Vi

Solved!
Go to solution

I wanted Labview to display the time in milliseconds and I got that to work. I want to display PM or AM after the milliseconds so it looks like this

 

05/31/11  4:45:39.849 PM

 

I am using %p as you can see in the picture, but it is not working. PM or AM does not show up.

 

What am I doing wrong?

Thanks in advance. 

0 Kudos
Message 1 of 13
(19,585 Views)
Solution
Accepted by kkroninger

Replace your %H with a %I. %H is 24 hour time which has no A.M or P.M designation. You need to use 12 hour time.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 13
(19,572 Views)

You need I instead of H for the hour portion.  H is for a 24 hour clock, so that wipes out any meaning for AM/PM.

 

I've never used Format into Date/Time String, and just use Format into String.  This gives you the ability to add other data into the string.

 

 

Message 3 of 13
(19,564 Views)

Why is it "H" for the 24 hour clock and "I "is for a 12-hour clock?  "I" is not logical at all other than the fact is follows "H".

 

I think it would make more sense the other way around.  "H" for the 12 hour clock and I for the 24-hour clock, since 12 comes before 24.  Also, "I" could mean "international".

0 Kudos
Message 4 of 13
(19,557 Views)

 


@Ravens Fan wrote:

Why is it "H" for the 24 hour clock and "I "is for a 12-hour clock?  "I" is not logical at all other than the fact is follows "H".

 

I think it would make more sense the other way around.  "H" for the 12 hour clock and I for the 24-hour clock, since 12 comes before 24.  Also, "I" could mean "international".


That notation is the ISO-C standard so you'd probably have to bring it up with them.  I tend to remember that 'I' stands for illogical and the 12-hour clock certainly qualifies.

Message 5 of 13
(19,552 Views)

I didn't realize there was an ISO standard on shortcuts.

What is interesting is that Excel's custom date codes for a cell format only use an "h".  It is the presence or lack thereof of the AM/PM in the date code that tells it to use the 12 hour clock or the 24 hour clock.

 


Darin.K wrote:
 

 I tend to remember that 'I' stands for illogical and the 12-hour clock certainly qualifies.

You lost me on that comment.

0 Kudos
Message 6 of 13
(19,542 Views)

Thank you for everyone who replied. All the comments were insightful and helpful. Thank you. 

 

0 Kudos
Message 7 of 13
(19,522 Views)

@Ravens Fan wrote:

I didn't realize there was an ISO standard on shortcuts.

What is interesting is that Excel's custom date codes for a cell format only use an "h".  It is the presence or lack thereof of the AM/PM in the date code that tells it to use the 12 hour clock or the 24 hour clock.

 


@Darin.K wrote:
 

 I tend to remember that 'I' stands for illogical and the 12-hour clock certainly qualifies.

You lost me on that comment.


IMO, other than colloquial use, the 12 hour format is woefully outdated.  Using it as a timestamp just does not make sense to me.  There is a two-fold degeneracy which is only broken by a separate am/pm flag (or is it a.m., AM, A.M.) so it takes more space and longer regexes to deal with.  These timestamps are not easily sortable, nor comparable without preprocessing.  That is part of the reason why I think it is 'illogical' to use it (for lack of a better mnemonic).   

 

And the ISO standard is on the C-language, of which these shortcuts are part.  I have a sneaking suspicion that I know what happens under the hood of the Format functions which use time codes...

0 Kudos
Message 8 of 13
(19,507 Views)

Okay, I agree with you there.  If I need to do anything that is text based, date and time format, I'll save it as 24hour data so that it can be sortable.  For instance, creating a filename based on date and time,  I'll do a year-month-day 24hr-min-sec format (with whatever punctuation/separators I feel like at the time to be somewhat readable) all zero filled so a month like June is 06, so that alphabetically sorting by that data also causes it to be chronologically sorted.

 

If it is just for the sake of a front panel display for the user to see a time, then I'll use 12 hour with am/pm and a normal month/day/year format so that the user doesn't have to do any mental math.  7:00 pm is meaningful,  1900 requires too much thinking.

Message 9 of 13
(19,504 Views)

Raven's I would disagree, but I think you use the default system formatting for any user controls, right?

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 10 of 13
(19,493 Views)