Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have already created a gridview and bind the data .it contains a field date containing both date and time.but now i only want to bind date only .How can it possible?
Posted

set this
C#
DataFormatString="{0:dd/MM/yyyy}"

to the gridview column

like
C#
<asp:BoundField DataField="completiondate" HeaderText="CompletionDate" 
 SortExpression="completiondate" DataFormatString="{0:dd/MM/yyyy}" />
 
Share this answer
 
v2
try:
C#
<asp:boundfield datafield="ColumnName" dataformatstring="{0:yyyy-MM-dd}" htmlencode="false" xmlns:asp="#unknown" />

for more refer:

http://www.aspdotnet-suresh.com/2011/05/how-to-set-date-format-in-gridview.html
 
Share this answer
 
Modify it in your query, in your select statement, do the ff:

SQL
SELECT CAST(GETDATE() AS DATE) AS 'DateToday'


OR

SQL
SELECT CONVERT(varchar(10), GETDATE, 111) AS 'DateToday'


Please mark as answer and vote 5 if this solved your problem

Regards,
Eduard
 
Share this answer
 
ASP.NET
<asp:boundfield datafield="Date" headertext="Date" xmlns:asp="#unknown">
 SortExpression="date" DataFormatString="{0:dd/MM/yyyy}" /></asp:boundfield>
 
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