Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change time string to am/pm
Message
 
 
To
01/08/2022 09:59:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01684752
Message ID:
01684754
Views:
32
>>Hi,
>>
>>Say I store the value of time in a string (e.g. "20:01" for 8:01pm). In a report, I would like this time to be shown in an American format, am/pm. I can display this time using CTOT(cTimeString) but it also shows a date (the current date).
>>Is there a way to use CTOT() and make sure that the DATE part is not showing?
>>
>>TIA
>
>if you add second parameter of 2 to TTOC() you get just the string value representing the time portion of a datetime value. This value in turn is affected by the SET HOURS setting,
>
>nSetHours = SET("HOURS")    && remember original setting
>tTest = {^2022.08.01 14:32:25}
>SET HOURS TO 24
>? TTOC(m.tTest,2)
>SET HOURS TO 12
>? TTOC(m.tTest,2)
>SET HOURS TO (m.nSetHours)   && restore original setting
>
Works excellent! Thank you very much. I will just need to put the above code into a function and call it on every row of the report, passing the value of the Time character.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform