Troubleshoot problems with datetime fields appearing on the front end of a SQL Server 2005 database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.