|
|
|
ผมจะหาระยะห่างของวันที่ได้ยังไงครับ เก็บเป็น datetime ใน sqlserver ครับ มีรูปแบบเป็น 22/1/2552 |
|
|
|
|
|
|
|
SELECT DATEDIFF(Year, StartDate, EndDate) AS NewDate
Return Value = 0 Year
SELECT DATEDIFF(quarter, StartDate, EndDate) AS NewDate
Return Value = 1 quarter
SELECT DATEDIFF(Month, StartDate, EndDate) AS NewDate
Return Value = 2 Month
SELECT DATEDIFF(dayofyear,StartDate, EndDate) AS NewDate
Return Value = 61 day
SELECT DATEDIFF(Day, StartDate, EndDate) AS NewDate
Return Value = 61 Day
SELECT DATEDIFF(Week, StartDate, EndDate) AS NewDate
Return Value = 9 Week
SELECT DATEDIFF(Hour, StartDate, EndDate) AS NewDate
Return Value = 1464 Hour
SELECT DATEDIFF(minute, StartDate, EndDate) AS NewDate
Return Value = 87840 minute
SELECT DATEDIFF(second, StartDate, EndDate) AS NewDate
Return Value = 5270400 second
DECLARE StartDate DATETIME
DECLARE EndDate DATETIME
SET StartDate ='2007-06-05'
SET EndDate ='2007-06-06'
SELECT DATEDIFF(millisecond, StartDate, EndDate) AS NewDate
Return Value = 86400000 millisecond
|
|
|
|
|
Date :
2009-01-24 15:43:27 |
By :
farmer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|