DataGrid DATE process???
-
hai, i m using ASP.NET with C# (.net 2005, 2.0 framework) here i have a datagrid which contains 10 columns. the 4,5,8 column contains date in the format (7/23/2007 12:00:00 AM). i want to change those date in (23-Jul-2007). the major key point in this is.... 1. Fields are dynamic, so i cant fix in DATABOUNDCOLUMN 2. The placement should be the same (i.e, 4,5,8 columns) 3. The data are filled to datagrid from SQL Server. How to achieve it? help me...... - KARAN
-
hai, i m using ASP.NET with C# (.net 2005, 2.0 framework) here i have a datagrid which contains 10 columns. the 4,5,8 column contains date in the format (7/23/2007 12:00:00 AM). i want to change those date in (23-Jul-2007). the major key point in this is.... 1. Fields are dynamic, so i cant fix in DATABOUNDCOLUMN 2. The placement should be the same (i.e, 4,5,8 columns) 3. The data are filled to datagrid from SQL Server. How to achieve it? help me...... - KARAN
Hi can acheive that in two ways.
John Sundar wrote:
i want to change those date in (23-Jul-2007).
- while writing query to retriew data from SQL server you need to use convert function. eg: select convert(varchar,DateColumn,105) from tablename 2) In databound of datagrid coloum u can foramt.
Regards, Sandeep Kumar.V
-
Hi can acheive that in two ways.
John Sundar wrote:
i want to change those date in (23-Jul-2007).
- while writing query to retriew data from SQL server you need to use convert function. eg: select convert(varchar,DateColumn,105) from tablename 2) In databound of datagrid coloum u can foramt.
Regards, Sandeep Kumar.V
Thanks sandeep kumar.V but the thing i need is "DD-MMM-YYYY" (this exact format). and also i need the alias name also... my exact query..... select convert(varchar,column1 as "Test column",106) from tbl_name how to achieve it?????
-
Thanks sandeep kumar.V but the thing i need is "DD-MMM-YYYY" (this exact format). and also i need the alias name also... my exact query..... select convert(varchar,column1 as "Test column",106) from tbl_name how to achieve it?????
John Sundar wrote:
select convert(varchar,column1 as "Test column",106) from tbl_name
the query is not correct..... select convert(varchar,column1,106) as "Test column" from tbl_name
Regards, Sandeep Kumar.V
-
John Sundar wrote:
select convert(varchar,column1 as "Test column",106) from tbl_name
the query is not correct..... select convert(varchar,column1,106) as "Test column" from tbl_name
Regards, Sandeep Kumar.V
Thanks a lot sandeep... i achieved 90% of my requirement. but i cant get the separator (any separator is OKAY) the output is "25 Jan 2007". my requirement is "25-Jan-2007". is there anyway to achieve it?, so that my requirement will get fulfilled 100% :)
modified on Saturday, April 12, 2008 3:12 AM
-
Thanks a lot sandeep... i achieved 90% of my requirement. but i cant get the separator (any separator is OKAY) the output is "25 Jan 2007". my requirement is "25-Jan-2007". is there anyway to achieve it?, so that my requirement will get fulfilled 100% :)
modified on Saturday, April 12, 2008 3:12 AM
Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg:
<asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />
Regards, Sandeep Kumar.V
-
Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg:
<asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />
Regards, Sandeep Kumar.V
Thanks a lot sandeep... nice to meet you......... :-O
-
Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg:
<asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />
Regards, Sandeep Kumar.V
I found the answer in query itself sandeep... just refer it SELECT REPLACE(CONVERT(VARCHAR, column_name, 106), ' ', '-') as "column 1" from tbl_name :) Take care...