2010. 10. 13. 16:35ㆍplming/DB
http://sqldud.blogspot.com/search/label/GetDate
DatePart - Get Part of the Date
-- Selecting the Current Year/Get Current Year/Separate Year Part from Date
Select DatePart(YY, GetDate()) as Current_Year
Result = INT = [2010]
-- Selecting the Current Quarter/Get Current Quarter/Separate Quarter Part from Date
Select DatePart(QQ, GetDate()) as Current_Quarter
Result = INT = [4]
-- Selecting the Current Month/Get Current Month/Separate Month Part from Date
Select DatePart(MM, GetDate()) as Current_Month
Result = INT = [10]
-- Selecting the Name of Current Month/Get Name of Current Month/Separate Month Part from Date and display its Name
Select DateName(month, GetDate()) as Current_Month_Name
Result = CHAR(30) = [October]
-- Selecting the Name of Current Month/Get Name of Current Month/Separate Month Part from Date and display its Name
Select DateName(day, GetDate()) as Current_Day
Result = CHAR(30) = [21]
-- Selecting the Name of Current Month/Get Name of Current Month/Separate Month Part from Date and display its Name
Select DateName(wk, GetDate()) as Current_Week
Result = CHAR(30) = [43]
Universal Time or Greenwich Meridian Time (GMT)
Getting the Universal Time - GMT
Select GetDate() as LocalTime
Result = DATETIME = [2010/10/21 오전 10:04:10]
Select GetUTCDate() as GMT_Time
Result = DATETIME = [2010/10/21 오전 1:04:10]
GetUTCDate Returns the datetime value representing the current UTC time (Coordinated Universal Time or Greenwich Mean Time)
Select DateDiff(second,GetDate(),GetUTCDate() ) as DifferenceinSec
Result = INT = [-32399]
will give you the difference between GMT and your Local Time
SELECT convert(DATE,"2010/08/23")
2010/08/23 오전 12:00:00
SELECT convert(DATETIME,"2010/10/21 13:34:56")
2010/10/21 오후 1:34:56
'plming > DB' 카테고리의 다른 글
Sybase - Error 원인 & 처리방법 (0) | 2010.11.22 |
---|---|
Sybase - This exceeds the maximum allowable limit of (0) | 2010.11.22 |
Sybase 15.0.1 vs Oracle 10.2 (0) | 2010.10.13 |
Sybase SQL등 명령어 (0) | 2010.08.26 |
Sybase , Oracle 함수 비교 (0) | 2010.08.26 |