Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 9 Jahren
Letzter Beitrag:
vor 9 Jahren
Beteiligte Autoren:
Joel, DW, Chris L

WB12 - Simple ? - How get a PM or AM on a time?

Startbeitrag von Joel am 08.08.2009 16:17

Hi -

I've looked through the help files, but can't find how to display a time as 5pm or 5:00pm instead of 05:00.


Hello Joel

I think by setting your input mask to something like this HH:MM AM

Dennis W

von DW - am 08.08.2009 18:56
Unfortunately - I don't have an input mask that displays an AM or PM. that's where I would have expected such a thing to be - it's really a bit frustrating that things aren't consistent like that - and that it's so hard to find anything deep & detailed in the help! But thanks anyway!

von Joel - am 09.08.2009 01:23
Hello Joel,

I have webdev but do not use it.

What kind of control are you displaying the time?
I tested a edit control I set the Input mask to HH:MM AM.

In the Initialization code put myself = now() and gave me the time 10:21 PM

I did read the help and it said:
Custom input mask are only managed in display mode: they are not available to the Web user when entering data in the control.

Hope this helps

Dennis W

von DW - am 09.08.2009 02:25

I'm not sure what control you're using but from your later posting it sounds like it could be an edit control.

If so, it's easy to get what you want. You can type in or modify whatever mask you want.

It's true that there's no specific mask for something like 10:21 PM.

[PC Soft have a logic of their own when it comes to masks. There are some really obscure masks included, obscure at least to English-language users, but obvious ones are missing. One of my ongoing beefs for many years is the lack of Title case, the capitalisation of the first letter of words such as when entering names and addresses - such an elementary function but one they've refused to do anything about for many many versions.]

However, it's easy to modify one of the existing masks. Select the mask HH:MM:SS AM which should be on the drop-down list. Now in the Input mask: box just remove the :SS characters. Voila!

The current time for me now is five past eight in the evening so using the above mask gives me 08:05 PM. Now I don't know about you but I really dislike times (and dates) with single digits prefaced by a 0. Why can't we just have 8:05 PM?

Well, you can. In the input mask, delete an H so that the mask is now H:MM AM. Hey presto! We now have 8:05 PM!

If you're displaying time in a static, then you need to explicitly convert the time variable to a string with the function TimeToString. With no options specified, this will simply output time in 24-hour format with hundredths of a second included, eg 20:07:48:22. To show this differently, you need to specify a mask as follows:

Static1 = TimeToString(Now(),"HH:MM AP")

The previous mentioned time will now display as 08:07 PM.

But this is where WinDev displays another of its little quirks. In the edit field, it's fine to have a mask of H:MM PM but if you try putting just a single H in the mask in the TimeToString function (or anywhere else where you specify a mask in quotes), it won't work.

Static1 = TimeToString(Now(),"H:MM AP")]

will display as H:07 PM! Go figure!


Chris L
Melbourne, Oz

von Chris L - am 09.08.2009 10:32
Thanks to you both! That should do it!


von Joel - am 09.08.2009 14:08
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.