SQL 은 전날, 1 월, 1 년 의 시간 을 가 져 옵 니 다.

1927 단어 데이터 뱅 크
SQL 은 전날, 1 월, 1 년 의 시간 을 취한 다.
 _______________________________________
월요일 부터 일요일 까지 일주일 간 의 수금 이다.
ASA: set DATEFIRST 1   --매주 첫 날 은 월요일 selectsum (isnull (cash. act amt, 0) 을 이번 수금 으로 설정 합 니 다. cash.customer_id as 고객 번호 from cash where cash.approved='Y' and cash.trans_date between convert (varchar (10), dateadd (day, 1 - datepart (weekday, getdate (), getdate (), 120) and convert (varchar (10), dateadd (day, 7 - datepart (weekday, getdate (), 120) -- 첫날 과 마지막 날
SQL 은 다음 과 같 습 니 다.
이번 주 마지막 날 꺼 내.
select DATEADD(WK,DATEDIFF(WK,0,GETDATE()),6) 
selection sum (isnull (cash. act amt, 0) 을 이번 수금 으로, cash.customer_id as 고객 번호 from cash where cash. approved = 'Y' and datediff (week, cash. trans date - 1, getdate ()) = 0 group 
이번 주 일요일 부터 토요일 까지 일주일 select * from tb where datediff (week, 시간 필드, getdate () = 0 지난주 select * from tb where datediff (week, 시간 필드, getdate () = 1 다음 주 select * from tb where datediff (week, 시간 구간, getdate ()))= - 1 --------------------------------------------------------------------------------------------------------------------------------------------------------------------= 0 -- 다음 달 선택 * 부터 TableName Where DateDiff (mm, GetDate (), DateTimCol) = 1  어제: dateadd (day, - 1, getdate () 내일: dateadd (day, 1, getdate () 지난달: month (dateadd (month, - 1, getdate ()) 이번 달: month (getdate () 다음 달: month (dateadd (month, 1, getdate))() = 1 -- 내일 Select * From TableName Where DateDiff (dd, GetDate (), DateTimCol) = 1 -- 최근 7 일 Select * From TableName Where DateDiff (dd, DateTimCol, GetDate ()) < = 7 -- 추 후 7 일  --------------------------------------------------------------------------- 현재 년 select  제출 날짜, datepart (year, getdate () as  현재 년 from 공급 자 자료 표 전년 도 select  제출 날짜, datepart (year, getdate () - 1 as  현재 년 from 공급 자 자료 표 후 1 년 select  제출 날짜, datepart (year, getdate () + 1 as  현재 년 from 공급 자 자료 표
 
 

좋은 웹페이지 즐겨찾기