Oh, congratulations I have broken 1000 points, add a hot spot---about the format of date data in ASP program (paste)

Source: Internet
Author: User
Tags odbc
Program | data | Problems whether it is MIS or intranet development, date-type data is always a headache, because the processing of it is not as arbitrary as the handling of numbers or strings, but horseshoes, the program does not pass.

In the development process of the web-webserver-database three-layer structure, date-type data is used more frequently, and the definition of date format is different for various databases, so you should first pay attention to how to define the format of the date when you edit the page. Otherwise, there will be an error in database submission and query operations. ASP (ACTIVE SERVER PAGES) is a server-side scripting environment in the webserver-iis4.0 provided by Microsoft, and when running on the server side, the Web server completes the description of the script, which is echoed to the client by standard HTML calls. ASP directly embed script in HTML file, make development and maintenance work become simple, fast and flexible. Development tools are available in normal text editors, FRONTPAGE 98, and so on. The ASP's script only interprets execution on the server side, the general user cannot see the concrete script in the browser side, this has the extremely help to the system security. At present, the application environment for win Nt+sql Server6+iis4, the author in addition to introducing the date format in this environment, but also introduces the win NT+ORACLE7+IIS4 application environment, through the comparison between the two, will deepen this understanding, The ASP scripting language used in this article is VB.

1 Environment 1

The operating system is a Web server IIS4.0 for the NT4.0,WWW server, and the database is SQL SERVER6.5.

1. 1 connection to the data source

The ODBC data source's name is Name_of_odbc,sql server database with a username of sql_server_dbname and a password of sql_server_dbpasswd.

Set Conn = Server.CreateObject ("ADODB. Connection ")

Conn.Open "Name_of_odbc", "Sql_server_dbname", "SQL_SERVER_DBPASSWD"




1. 2 using an array variable to store the 12-month portion,
1. 3 Environment 2 also need to use,
1. 4 does not
1. 5 Repeat again
1. 6 description

Dim Month1_12 (12)

Month1_12 (1) = "A few"

Month1_12 (2) = "Feb"

Month1_12 (3) = "Mar"

Month1_12 (4) = "APR"

Month1_12 (5) = "May"

Month1_12 (6) = "June"

Month1_12 (7) = "June"

Month1_12 (8) = "Aug"

Month1_12 (9) = "Sep"

Month1_12 (+) = "Oct"

Month1_12 (one) = "Nov"

Month1_12 (a) = "Dec"


1. Assignment of the 3rd-year variable

Ini_timevalue = Date ()

The form is displayed in the Output box as: 1999-4-8

Ini_timevalue = REQUEST (ini_timevalue)

Def_timevalue = Day (ini_timevalue) & "-" & Month1_12 (Month (ini_timevalue)) & "-" &year (Ini_timevalue)


The value of the Def_timevalue is 8-apr-1999, and SQL Server recognizes only date data in this format when it is in storage.

2 Environment 2

2. 1 connection to the data source

The ODBC data source's name is Name_of_odbc,oracle7 database with a username of oracle_dbname and a password of oracle_dbpasswd.

Set Conn = Server.CreateObject ("ADODB. Connection ")

Conn.Open "Name_of_odbc", "Oracle_dbname", "ORACLE_DBPASSWD"


2. Assignment of the 2nd-year variable

Ini_timevalue = Date ()

The form is displayed in the Output box as: 1999-4-8

Ini_timevalue = REQUEST (ini_timevalue)

Def_timevalue = Day (ini_timevalue) & "-" & Month1_12 (Month (ini_timevalue)) & "-" &year (Ini_timevalue)


The value of the Def_timevalue is 8-apr-1999, and ORACLE7 does not recognize date data in this format when it is in storage. Instead of identifying the data in the 8-apr-99 format, you can adjust the assignment statement as you program:

Def_timevalue = Day (ini_timevalue) & "-" & Month1_12 (Month (ini_timevalue)) & "-" & Mid (Ini_ TimeValue), 3,2)

After the year is taken two digits, the Def_timevalue value becomes 8-apr-99, so that the ORACLE7 database can recognize the



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.