Friday, August 21, 2009

PeopleCode Time formatting

Had a record with a Time field, took a little while to figure out how to format the value since you can't pass a Time value directly into the builtin DateTimeToLocalizedString function.


/* &time is a record field defined as Time */
Local datetime &dateTime = DateTime6(1900, 1, 1, Hour(&time), Minute(&time), Second(&time));
Local string &formattedTime = DateTimeToLocalizedString(&dateTime, "h:mm a");

7 comments:

Jim Marion said...

I've fought that battle myself John. Here is how I get a DateTime value DateTimeValue("01/01/1900 " | &time)

John Wagenleitner said...

Thanks Jim, you code is much more succinct than mine.

gogle said...

Awesome! what a heavy beautiful blog
full software download Full software download

tenax_technologies said...

Great blog!
Thanks for sharing.

--------
Tenax Technologies is a Belarussian software company delivering complex web solutions. We provide comprehensive software development for startups based on Java J2EE Spring Hibernate web2.0 technologies.

joncena said...

This is a very nice blog,I have seen this variety of post after a elongated moment. I value your endeavor for compiling such post.
Dissertation Editing

clum

pixymagic said...

I would really like your post ,it would really explain each and every point clearly well thanks for sharing.
Chevy HHR Turbo

gholi said...

Now there is a group blogging system gone live at http://www.bashpost.com/ it will help all people to get in touch with similar minded people around us. You can easily paste your posts there as well to be more heard.