Formatting of time and date in VB.net

Source: Internet
Author: User

In the IDC charging system, the date is used for query, so the automatic date addition function is not used in the data table, but is inserted in a custom format. However, due to the absence of a unified format for time conversion in advance, problems may occur during subsequent queries.

The format of the insert time must be consistent, otherwise there may be no results during the query. The conversion format of time and date is very knowledgeable and cannot be converted incorrectly. The following uses the format function as an example (of course, there are many other conversion methods ):

Time Format:

  Format(Now(),"HH:mm:ss")

 

Date Format:

  Format(Now(),"yyyy/MM/dd")

 
If you change the mm in the time format to mm, the result will not be the time. After continuous exploration, the following conclusions are drawn:

In the time and date Formatting Function, MM indicates the month, MM indicates the minute, HH indicates the 24-hour system, and HH indicates the 12-hour system. You must note these four points! Other letters must be in lower case; otherwise, the characters are displayed. It doesn't matter whether the delimiter ":", "/", or "-" is used, as long as it is unified.

The datepicker control is used in the report. During query, we need to change its default format to the same format as that in the data table. The implementation method is as follows:

First, set the format attribute to custom, and then set the desired format in the customformat attribute.

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.