Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hours/Minutes and using PAD in SQL
Message
From
12/12/2007 18:55:04
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
 
To
12/12/2007 17:17:09
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01275327
Message ID:
01275370
Views:
9
>>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform