Hi,
Maybe a stupid question, but I was wondering if there is an overview of the different formatstrings you can use for the DateTime Column?
I want to make a static function where I just need to call the right formatString, instead of every time searching the "net" for the right syntacs and add it.
Thanks
Maybe a stupid question, but I was wondering if there is an overview of the different formatstrings you can use for the DateTime Column?
I want to make a static function where I just need to call the right formatString, instead of every time searching the "net" for the right syntacs and add it.
Thanks
6 Answers, 1 is accepted
0
Hello Gerbrand,
These are some samples of formatting DateTime column in RadGridView:
You can find more information for DateTime formatting in MSDN.
Greetings,
Julian Benkov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
These are some samples of formatting DateTime column in RadGridView:
GridViewDateTimeColumn column = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"]; |
column.DataTextFormatString = "{0:hh.mm.ss}"; //hour.minutes.seconds |
column.DataTextFormatString = "{0:dd.MM.yy}"; //day.month.year |
column.DataTextFormatString = "{0:hh.mm}"; //hour.minutes |
column.DataTextFormatString = "{0:dd.MMMM.yy}"; //day.long month name.year |
column.DataTextFormatString = "{0:dd-MM-yy}"; //day-month-year |
You can find more information for DateTime formatting in MSDN.
Greetings,
Julian Benkov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

tuonglam
Top achievements
Rank 1
answered on 09 Sep 2011, 10:20 AM
I'm using like you say but i have a error.I'm using in Formload
My code:
thank you very much!
'Telerik.WinControls.UI.GridViewDateTimeColumn' does not contain a definition for 'DataTextFormatString' and no extension method 'DataTextFormatString' accepting a first argument of type 'Telerik.WinControls.UI.GridViewDateTimeColumn' could be found (are you missing a using directive or an assembly reference?)
My code:
GridViewDateTimeColumn column = (GridViewDateTimeColumn)this.radGridView1.Columns["Date"];
column.DataTextFormatString = "{dd-MM-yy}"; //day-month-year
thank you very much!
0
Hi Tuonglam,
I hope this helps. Greetings,
Nikolay
the Telerik team
The code snippet provided by my colleague Julian concerned a version of RadControls for WinForms issued during 2009. If you are using one of the latest versions, you have to use the FormatString property as shown below:
GridViewDateTimeColumn column = (GridViewDateTimeColumn)
this
.radGridView1.Columns[
"Date"
];
column.FormatString =
"{0:hh.mm.ss}"
;
//hour.minutes.seconds
column.FormatString =
"{0:dd.MM.yy}"
;
//day.month.year
column.FormatString =
"{0:hh.mm}"
;
//hour.minutes
column.FormatString =
"{0:dd.MMMM.yy}"
;
//day.long month name.year
column.FormatString =
"{0:dd-MM-yy}"
;
//day-month-year
I hope this helps. Greetings,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Scott
Top achievements
Rank 1
answered on 10 Feb 2017, 10:22 PM
How does this work if the SQL Server datatype is TimeSpan?
Thank you.
-Scott
0
Hi Scott,
By default, the grid will create a GridViewTextBoxColumn, but you can replace the default text editor with the desired one in the EditorRequired event. Note that if the applied editor is not compatible with the TimeSpan value, it would be necessary to implement a Type Converter. A sample approach is demonstrated in the following help article: http://docs.telerik.com/devtools/winforms/gridview/columns/converting-data-types
In addition, we have a feature request for this in our Feedback Portal. I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comment to it here.
I hope this information is useful. Let me know if you need further assistance.
Regards,
Dimitar
Telerik by Progress
By default, the grid will create a GridViewTextBoxColumn, but you can replace the default text editor with the desired one in the EditorRequired event. Note that if the applied editor is not compatible with the TimeSpan value, it would be necessary to implement a Type Converter. A sample approach is demonstrated in the following help article: http://docs.telerik.com/devtools/winforms/gridview/columns/converting-data-types
In addition, we have a feature request for this in our Feedback Portal. I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comment to it here.
I hope this information is useful. Let me know if you need further assistance.
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0

Scott
Top achievements
Rank 1
answered on 13 Feb 2017, 04:10 PM
Hi Dimitar-
Thank you for the feature up vote and the interim guidance.
-Scott