I am adding rows to a runtime table as following"
dtRecords.Rows.Add("RecordingDate", typeof(DateTime));
the date is stored as long datetime but I want to view the date date only in thos runtime table:
the date appears as following: 0206/2008 12:00:00 am
but I want it to appear as following:0206/2008
i.e,the date with out the time.
does any one has an idea?

thnx in advance

what type of object is that dtRecords.is it DataTable class's object.then finally u will bind this datatable to gridview or datalist control isn't it.thre u can specify the date format.
set DataFormatString property if it is a boundfield
if it is itemtemplate then give format string as second argument to Eval menthod.
hope this will help...let me wait for ur responce...

thnx for ur reply,

dtRecords is a table that I created in runtime and the grid view columns is not specified in the design so I want to specify the datetime format through this.line:
dtRecords.Rows.Add("RecordingDate", typeof(DateTime));
is there any modification to this line to change the datetime format to show date only.
do you understand me.

thnx in advance.

thnx for ur reply,

dtRecords is a table that I created in runtime and the grid view columns is not specified in the design so I want to specify the datetime format through this.line:
dtRecords.Rows.Add("RecordingDate", typeof(DateTime));
is there any modification to this line to change the datetime format to show date only.
do you understand me.

thnx in advance.

Web:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=181

VB:
http://programming.top54u.com/post/ASP-Net-VB-Format-DateTime-Using-ToString-Function.aspx

dtRecords.Rows.Add("RecordingDate", DateTime.Now); // Current Date
dtRecords.Rows.Add("RecordingDate", DateTime.Parse("12/31/2002"));

DataFormatString should be {0:dd/MMM/yyyy}

I am adding rows to a runtime table as following"

dtRecords.Rows.Add("RecordingDate", typeof(DateTime));

You can add rows to a DataTable using the following syntax

DataTable.Rows.Add(DataRow) ;
DataTable.Rows.Add(Object[] ) ;

But you are passing two arguments. Are you passing column name in you code ('RecordingDate').


How is it possible?

Yes, It's called param array arguments.

I am adding rows to a runtime table as following"
dtRecords.Rows.Add("RecordingDate", typeof(DateTime));
the date is stored as long datetime but I want to view the date date only in thos runtime table:
the date appears as following: 0206/2008 12:00:00 am
but I want it to appear as following:0206/2008
i.e,the date with out the time.
does any one has an idea?

thnx in advance

hi try to format recordingdate field in date only format for ex.

in query date field is write like convert(datetime,fildname,103) or
convert(nvarchar,fildname,103)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.