Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting character 3:45 PM to 15 and 45 numeric
Message
 
À
07/02/2008 17:13:14
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01290609
Message ID:
01290623
Vues:
12
>>
>>cTime = "03:45pm"
>>?HOUR(CTOT("1/1/01 "+cTime))
>>?MINUTE(CTOT("1/1/01 "+cTime))
>>
>
>How does that work? I did work, but it's like magic! Ok, I know it's not magic...

You are just building a DateTime string by adding your time entry to a valid date (1/1/01). Then when you do a CTOT you get a DateTime value which you can pull the HOUR and MINUTE from.

If you are dealing with differnt date formats (other the MDY format) you could try:
cTime = "03:45pm"
?HOUR(CTOT(DTOC(DATE())+" "+cTime))
?MINUTE(CTOT(DTOC(DATE())+" "+cTime))
This makes sure the date format is whatever your date settings are.

Also, I noticed that a TRY...CATCH is not necessary, if the time is an invalid entry, the HOUR and MINUTE return 0
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform