1. Get Time
Get data for the day
where DATEDIFF (DD, field of time in database, GETDATE ()) =0
Query within 24 hours of
where DATEDIFF (HH, field of time in database, GETDATE ()) =0
Get data for the week
where DATEDIFF (WEEK, Dt_uploadtime, GETDATE ()) =0
* Get data for this week, if it's Monday or no data, you can simulate nearly a week of data *:where DATEDIFF (DD, the field of time in the database, GETDATE ()) <=7
Get the data for this month
where DATEDIFF (MONTH, Dt_uploadtime, GETDATE ()) =0
* Get data for this month, similar to a week, a number maybe no data, can simulate the data of nearly January *:where DATEDIFF (DD, the field of time in the database, GETDATE ()) <=30
system Date Time : getdate ()
Add a time or a period of time to a date
Select DATEADD (Day,-2,getdate ())
function : Datadiff (datepart,startdate,enddate) * returns the number of date and time boundaries across two specified dates *
Select DateDiff (Day, ' 2004-09-01 ', ' 2004-09-18 ')--return:
DATEPART () * Returns an integer representing the specified date part of the specified date *
SELECT DATEPART (month, ' 2004-10-15 ')--return
or use day (), month (), year (), and so on.
Datename () * Returns a string representing the specified date part of the specified date *
SELECT Datename (Weekday, ' 2004-10-15 ')--return: Friday
2. Paging
SELECT * FROM (select Row_number () up (order by dt_uploadtime desc) as num, * from Photo)
As TBL
where Tbl.num between (@pageIndex-1) *pagenum+1 and @pageIndex * @pageNum
PageIndex: Represents the current page Pagenum: Indicates the number of bars displayed per page
Get time SQL Function statement