Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hours/Minutes and using PAD in SQL
Message
De
12/12/2007 18:55:04
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
12/12/2007 17:17:09
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01275327
Message ID:
01275370
Vues:
8
>>The combination padl(alltrim(str(... seems a little too involved.
>>
>>I think you can use the simpler padl(int(Schedule.s_MM), 2, "0") - or even omit int() if the field is already an integer.
>>
>>>If time is 11:15 (s_HH = 9 and s_MM = 15), I get "200712121115"
>>>If time is 9:15 (s_HH = 9 and s_MM = 15), I get "20071212915"
>>>
>>>What I want when the time is 9:15 is "200712120915"
>>>
>>>If I add PADL to it like this:
>>>
>>>
>>>	PADR(DTOS(s_Date) + PADL(ALLTRIM(STR(Schedule.s_HH * 100)), 2, '0') + ;
>>>		PADL(ALLTRIM(STR(Schedule.s_MM)), 2, '0'), 30, ' ')    AS Temp ;
>>>
>>>
>>>The result looks like this "200712129015"
>
>
padr(dtos(s_date)+transform(schedule.s_hh, "@L 99")+transform(schedule.s_mm, "@L 99"),30)
>
>
>I don't understand why were you multiplying hours with 100. Str(900) would be " 900", then allt() would give "900" and eventually padl("900",2,"0") gives "90". I simply prefer transform() with "@L" in the function part - old habit from 2.0.

That was brilliant! Exactly what I needed.

It's legacy code that I'm trying to fix.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform