quinta-feira, 2 de agosto de 2012
FxGqlC: Added support for DateTime datatype
SELECT convert(string, convert(datetime, '2012-07-13'), 'yyyyMMdd HH:mm:ss')
-- Formats datetime using a format string, as defined by the .net Framework
-- "Standard Date and Time Format Strings" (http://msdn.microsoft.com/en-us/library/az4se3k1), and
-- "Custom Date and Time Format Strings" (http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx)
SELECT datepart(day, '2012-07-13') -- returns 13
-- valid datepart values are: (with examples for '2012-07-12 23:59:50.1234567')
-- year, yy, yyyy : 2012
-- quarter, qq, q : 3 (1 ... 4)
-- month, mm, m : 7 (1 ... 12)
-- dayofyear, dy, y : 194 (1 ... 366)
-- day, dd, d : 12 (1 ... 31)
-- weekday, dw, w : 5 (1 = Sunday ... 7 = Saturday)
-- hour, hh, h : 23 (0 ... 23)
-- minute, mi, n : 59 (0 ... 59)
-- second, ss, s : 50 (0 ... 59)
-- millisecond, ms : 123 (0 ... 999)
-- microsecond, mcs : 123456 (0 ... 999999)
-- nanosecond, ns : 123456700 (0 ... 999999900)
SELECT dateadd(day, 10, '2012-07-03')
-- returns 2012-07-13
SELECT datediff(day, '2012-07-03', '2012-07-13')
-- returns 10
SELECT datediff(day, '2012-07-12 23:59', '2012-07-13 00:01')
-- returns 1, the number of day-boundaries crossed (as in T-SQL)
SELECT datediff(day, '2012-07-13 23:59', '2012-07-13 00:01')
-- returns 0
SELECT datediff(day, '2012-07-14 23:59', '2012-07-13 00:00')
-- returns -1
SELECT getdate(), getutcdate()
-- returns current DateTime in local and UTC/GMT time
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário