Click here to Skip to main content
15,903,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i used a calender extender with the text box to enter the date into table and showing that date in the Grid View and it shows both date and time but i want to show date only in the grid view so please tell me what i need to do?
Posted

while fetching the data from table in sql use convert to char, then it won't show timing in the grid view

for eg
SQL
select convert(char,colmname) from tblname

or use convert.Tostring() in front end.
 
Share this answer
 
The DateTime object in .Net has a ToString method with a large number of overrides.

You can use this to get just the date part but there are many ways using locales and globalization.

But in the simplest term, if you're not worry about multi national programming you could do this:

C#
DateTime.Now.ToString("dd/MM/yyyy")
or
C#
DateTime.Now.ToString("MM-dd-yyyy")


If you want to use the locale settings you could try:

C#
DateTime.Now.ToShortDateString()
or
C#
DateTime.Now.ToLongDateString()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900