473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need to have ShortDateTime Format with Datetime Type in DataGrid

I can't believe I have never run into this before but, I have an object that
has a property of type DateTime. A collection of these objects are used to
populate my DataGrid. In DateTime format they display the date AND the time,
I don't need nor want the time just the date. If I format at any point to a
ShortDate I have to convert the type to a string which when applied to the
grid interferes with sorting.
Is there any way to keep the datatype as DateTime but display only Date?
Oct 7 '05 #1
2 7761
I believe the DateTime class has a "Date" property which returns a DateTime
object with the time stripped I believe

Also, the ToString() method on DateTime has an override where you can pass a
format string, so you can do:

DateTime dtNow = DateTime.Now;
MessageBox.Show(dtNow.ToString("MM/dd/yyyy"));

"A Programmer" <AP*********@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
I can't believe I have never run into this before but, I have an object
that
has a property of type DateTime. A collection of these objects are used to
populate my DataGrid. In DateTime format they display the date AND the
time,
I don't need nor want the time just the date. If I format at any point to
a
ShortDate I have to convert the type to a string which when applied to the
grid interferes with sorting.
Is there any way to keep the datatype as DateTime but display only Date?

Oct 7 '05 #2
Neither works, but thanks.

"Nathan C." wrote:
I believe the DateTime class has a "Date" property which returns a DateTime
object with the time stripped I believe

Also, the ToString() method on DateTime has an override where you can pass a
format string, so you can do:

DateTime dtNow = DateTime.Now;
MessageBox.Show(dtNow.ToString("MM/dd/yyyy"));

"A Programmer" <AP*********@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
I can't believe I have never run into this before but, I have an object
that
has a property of type DateTime. A collection of these objects are used to
populate my DataGrid. In DateTime format they display the date AND the
time,
I don't need nor want the time just the date. If I format at any point to
a
ShortDate I have to convert the type to a string which when applied to the
grid interferes with sorting.
Is there any way to keep the datatype as DateTime but display only Date?


Oct 7 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Niall Porter | last post by:
Hi all, I'm building an ASP app on a Windows 2000/IIS machine which interfaces with our SQL Server 2000 database via OLE DB. Since we're based in the UK I want the users to be able to type in...
0
by: Wilfried Mestdagh | last post by:
Hi, I query Access database with dataGridview using the code listen hereafter. The problem is that the datetime format is not displayed as it is set in my machine. It is displayed in american...
10
by: ruca | last post by:
Hi I want to format some columns of my DataGrid control. Example, one of my fields of DataSet is a DATE field and in BD he is Ok, but when I show him in datagrid he comes with hours too. I...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
2
by: A Programmer | last post by:
I can't believe I have never run into this before but, I have an object that has a property of type DateTime. A collection of these objects are used to populate my DataGrid. In DateTime format they...
3
by: INeedADip | last post by:
I have seen this problem posted all over, but have never ran across a solution.... I am serializing my dataset and they look like this: <NewDataSet> <xs:schema id="NewDataSet" xmlns=""...
1
by: Charlie Brown | last post by:
I would like to make my datagrid show a blank text field for datetime values that are DBNULL. Does any know how to format that way?
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
0
by: webaccess | last post by:
Hi Friends ..!! I want to use datagrid/dataview control to data in tablular format,also I want to add paging and format the data of table column. Problem is data is coming from API Dom in as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.