This is a migrated thread and some comments may be shown as answers.

How to format a time field, please?

4 Answers 1360 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
davortsan
Top achievements
Rank 1
davortsan asked on 16 Nov 2015, 07:09 PM

Hi mates,

 I have a dataset in a telerik report. The dataset returns a time column. I would like to use the Format function to show it in hh:mm format. If I use Format('{0:hh:mm}', Fields.CreationTime), there is an exception. Currently, I'm using a "manual" transformation, using Fields.CreationTime.Hours + ":" + Fields.CreationTime.Minutes but this is not a solution for me because if the CreationTime is 12:00, the report shows 12:0. I would like to use the Format function OR show the minutes using two digits. How could I resolve my issue, please?

 Thanks a lot in advance.

 Cheers.

David Ortega

4 Answers, 1 is accepted

Sort by
0
Accepted
davortsan
Top achievements
Rank 1
answered on 16 Nov 2015, 09:14 PM

Hi mates,

I've found a similar issue and this resolved my problem:

    Fields.CreationTime.Hours.ToString("N0") + Fields.CreationTime.ToString("\:mm")

Thanks a lot for your help.

Cheers.

David Ortega.

0
Davi
Top achievements
Rank 1
answered on 27 Aug 2020, 12:38 PM
I had the same problem.  I figured out one solutions is escape the second ":"

Format('{0:hh\:mm}', Fields.CreationTime)  



0
Silviya
Telerik team
answered on 31 Aug 2020, 07:20 AM

Hello Davi,

I'm happy that escaping the ":" resolved the issue.

Still, for detailed information about date and time format specifiers can be found in Standard Date and Time Format Strings and Custom Date and Time Format Strings articles.

Best Regards,
Silviya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Brajalal
Top achievements
Rank 1
Iron
answered on 28 Feb 2023, 05:14 AM
Try this
=Format("{0: h\:mm tt}",Fields.date)
Tags
General Discussions
Asked by
davortsan
Top achievements
Rank 1
Answers by
davortsan
Top achievements
Rank 1
Davi
Top achievements
Rank 1
Silviya
Telerik team
Brajalal
Top achievements
Rank 1
Iron
Share this question
or