Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi all,
I want to remove time from a date in datagridview(winform application). when i search in net they all have given about asp.net gridview . but i want to know how to change that in winform application.

thanks
parithi
Posted
Comments
manognya kota 2-Feb-12 0:55am    
What are you using for displaying date? a datetimepicker? or anything else?Please clarify

SQL
To Format as dd/MM/yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd/MM/yyyy";
To Format as dd/MMM/yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd/MMM/yyyy";
To Format as dd-MMM-yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd-MMM-yyyy";
 
Share this answer
 
Hi friend,

try this querry :This may help you


select convert(varchar(20),Date_ColumnName,101) as [Date] from Database_Name



Or Use this in Data Grid View
dataGridView1.Columns[0].DefaultCellStyle.Format = "dd/MM/yyyy";
C#

 
Share this answer
 
v3
Comments
Rajesh Anuhya 2-Feb-12 1:16am    
Code tags added
--RA
See the below links to get different date formats in sql server

http://www.sql-server-helper.com/tips/date-formats.aspx[^]
http://www.technoreader.com/SQL-Server-Date-Time-Format.aspx[^]

Thanks
--RA
 
Share this answer
 
you can use with C#

var dateAndTime = DateTime.Now;
var date = dateAndTime.Date;

The date variable will contain the date.
 
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