Data center charging system-how to query data between two dates

Source: Internet
Author: User
The calendar control just learned how to query the data syntax between the two statements. I am eager to check the data syntax on the Internet and try it myself, but every time I do not have a syntax error, I cannot connect to the database. I feel that this method is in front of me.

The calendar control just learned how to query the data syntax between the two statements. I am eager to check the data syntax on the Internet and try it myself, but every time I do not have a syntax error, I cannot connect to the database. I feel that this method is in front of me.

The calendar control just learned how to query the data syntax between the two statements. I am eager to check the data syntax on the Internet and try it myself, however, every time I do not have a syntax error or cannot connect to the database, I feel that this method is in front of my eyes. I just can't get it out, so I am struggling. The following code queries the two calendar controls.

Private Sub commandateclick () date1 = DTPicker1.Value 'This is the calendar control date2 = DTPicker2.Value' that compares the sizes of two dates If DateDiff ("n", CDate (date1), CDate (date2 )) <0 Then MsgBox "the start date conflicts with the end date. Please reselect the date ",, "prompt" Exit Sub End If txtSQL = "select * from Recharge_Info where date> = '" & date1 & "' and date <= '" & date2 & "'" Set mrc = executeSQL (txtSQL, msgtext) If mrc. EOF = True Then MsgBox "No information" Exit Sub End If With MSFlexG Rid1 Do While mrc. EOF = False. CellAlignment = 4. Rows =. Rows + 1. TextMatrix (. Rows-2, 0) = mrc! Cardno. TextMatrix (. Rows-2, 1) = mrc! Addmoney. TextMatrix (. Rows-2, 2) = mrc! Date. TextMatrix (. Rows-2, 3) = mrc! Time. TextMatrix (. Rows-2, 4) = mrc! UserID. TextMatrix (. Rows-2, 5) = mrc! Status mrc. MoveNext If mrc. EOF = True Then. Rows =. Rows-1 End If Loop End With mrc. CloseEnd sub
I wrote a lot about it. The most useful thing is this sentence.
TxtSQL = "select * from Recharge_Info where date> = '" & date1 & "' and date <= '" & date2 &"'"
This method can be used not only to compare dates, but also to compare data with numbers!

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.