There are many ways in which time can be stored in a database, but it is mainly date-oriented, with Oracle as an example
Typically write a time condition directly in a database statement for example: c_datetime<= ' 2014-08-06 ' or between time1 and time2 error
The more classic error is ora-01861:literal does not match format string
The text does not match the format string
A multiple string is required to convert at this time:
To_date (' time1 ', ' yyyy-mm-dd hh24:mi:ss ')
In the concrete time range statement splicing, the general logic is that if the user sets the start time/end time, the logical limit of the stitching start time \ End time in the query statement
SQL is a query statement
if (begintime. =null) {
SQL =sql + "and ps.cost_datetime>=to_date (' + bgdate + 00:00:00 ', ' yyyy-mm-dd hh24:mi:ss ')"; PS as a table abbreviation
}
if (endtime!=null) {
sql = sql + "and ps.cost_datetime<=to_date (' + eddate + 23:59:59 ', ' yyyy-mm-dd hh24:mi:ss ')"; PS as a table abbreviation
}
Here you need to see that the general time range includes the same day, so start time starts with 00:00:00, end time ends with 23:59:59
This allows you to query for a time range comparison
General query also need paging display, page display will generally query two times, once for the query to meet the criteria of the number of, once for each specific record
If a time limit is added, add the time constraint to the statement in the number of query bars
For specific paging statements, refer to the previous article
Specific time date range query can refer to http://www.2cto.com/database/201205/132096.html