超碰人人人人人,亚洲AV午夜福利精品一区二区,亚洲欧美综合区丁香五月1区,日韩欧美亚洲系列

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

SQL查詢月、天、周、年(MySql的實例對比)

admin
2010年7月3日 16:4 本文熱度 6392

sql server實現(xiàn)
日期部分 縮寫 year yy, yyyy quarter qq, q month mm, m dayofyear dy, y day dd, d week wk, ww weekday dw hour hh minute mi, n second ss, s millisecond ms


/**//*計算今天是星期幾*/
select datename(weekday,getdate())

/**//*查詢本年的數(shù)據(jù)*/
select from users where year(time)=year(getdate())  

/**//*查詢本月的數(shù)據(jù),time是表users中代表時間的字段*/
select from users where month(time)=month(getdate()) and year(time)=year(getdate())

/**//*查詢今天的數(shù)據(jù),time 是表中代表時間的字段*/
select from users where day(time)=day(getdate()) and month(time)=month(getdate()) and year(time)=year(getdate())


/**//*計算那一天是星期一*/
select dateadd(wk,datediff(wk,0,getdate()),0)  

/**//*計算那一天是周末*/
select dateadd(wk,datediff(wk,0,getdate()),6)

/**//*查詢本周的數(shù)據(jù)*/
select from users where datepart(wk, time)=datepart(wk,getdate()) and datepart(yy, time)=datepart(yy,getdate())


/**//*查詢本日的記錄*/
select from users where(datediff(dd, time,getdate())=0)

/**//*查詢本月的記錄*/
select from users where(datediff(mm, time,getdate())=0)

/**//*查詢本年的記錄*/

select from users where(datediff(yy, time,getdate())=0)


在mysql中實現(xiàn):
1——  
本年:  
select from loaninfo where year(date)=year(getdate())  

2——  
本月:  
select from loaninfo where year(date)=year(getdate()) and month(date)=month(getdate())  

3——  
本日:  
select from loaninfo where year(date)=year(getdate()) and month(date)=month(getdate()) and day(date)=day(getdate())


該文章在 2023/4/7 23:36:35 編輯過
關鍵字查詢
相關文章
正在查詢...
點晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運作、調(diào)度、堆場、車隊、財務費用、相關報表等業(yè)務管理,結(jié)合碼頭的業(yè)務特點,圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點晴WMS倉儲管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務都免費,不限功能、不限時間、不限用戶的免費OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved