The format of a DateTime in SQL Server 2005 is "date and time", which is read directly out of the field, in order to keep it from appearing on the front "seconds and minutes" if displayed in DataGridView, you can modify a column format for the control, such as:
datagridview1.columns[10]. Defaultcellstyle.format = "Yyyy-mm-dd";
However, in the ListView control, it is a bit difficult, seemingly no similar attributes, so, consider starting from the data source.
1. Date of acquisition: Select CONVERT (varchar), GETDATE (), 111)
2. Read directly from the table field: Select convert (varchar (), date_in,111) from S, where date_in is a datetime field of type Date.
3. Build View: SELECT CONVERT (VARCHAR (date_in,111) as admission year from S;
4. Modify the View: You can modify it on the basis of the view built with the mouse pinch, and modify it on the automatically generated code under "Modify the View Interface": Select Dbo.s.sname as name, convert (varchar (20), dbo.s.date_in,111) as admission time, dbo. Unit_s.uname as unit name from s,unit_s where s.u#=unit_s.u#;
--------------------------------------------------------------------------------------------------
For date-time conversion issues, refer to: SQL Time date Conversion Daquan
Troubleshoot problems with datetime fields appearing on the front end of a SQL Server 2005 database