DATEDIFF ( datepart , startdate , enddate )

Return Type int

 

datepart

Abbreviations

year

yy, yyyy

quarter

qq, q

month

mm, m

dayofyear

dy, y

day

dd, d

week

wk, ww

hour

hh

minute

mi, n

second

ss, s

millisecond

ms

microsecond

mcs

nanosecond

ns

 

http://msdn.microsoft.com/en-us/library/ms189794.aspx

 

DATEDIFF (Transact-SQL) - SQL Server

DATEDIFF (Transact-SQL) In this article --> APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This function returns the count (as a signed integer value) of the specified datepart boundaries crossed between the spec

docs.microsoft.com

 

반응형

'Database > MSsql' 카테고리의 다른 글

[MSSQL] AUTOINCREMENT 설정하기  (739) 2013.10.17
MS-SQL DATETIME CONVERT  (59) 2013.08.29
MSSQL AUTO INCREMENT INIT  (57) 2013.07.04
[MSSQL] Database 복원  (0) 2013.05.07

MYSQL에서는 KEY값에다가 AUTOINCREMENT 라고 써주며 되었던 것 같은데, MSSQL에서는 조금 다른 것 같다.

 

| 방법1. CREATE TABLE

테이블 생성 할 때, 컬럼명 옆에 아래와 같이  IDENTITY 라고 작성해 준다. 

   [MEDIA_SEQ] [int] IDENTITY(1,1) NOT NULL,
    [CATEGORY] [nvarchar](50) NOT NULL,
    [FIMENAME] [nvarchar](50) NOT NULL,

 

| 방법2. Microsoft SQL Server Management studio 

반응형

'Database > MSsql' 카테고리의 다른 글

[MSSQL] DATEDIFF ( datepart , startdate , enddate )  (0) 2014.08.29
MS-SQL DATETIME CONVERT  (59) 2013.08.29
MSSQL AUTO INCREMENT INIT  (57) 2013.07.04
[MSSQL] Database 복원  (0) 2013.05.07

2007/09/21 14:35

 

 

번호

출력값

사용방법

0

Feb 22 2006 4:26PM

CONVERT(CHAR(19), CURRENT_TIMESTAMP, 0)

1

02/22/06

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 1)

2

06.02.22

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 2)

3

22/02/06

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 3)

4

22.02.06

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 4)

5

22-02-06

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 5)

6

22 Feb 06

CONVERT(CHAR(9), CURRENT_TIMESTAMP, 6)

7

Feb 22, 06

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 7)

8

16:26:08

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 8)

9

Feb 22 2006 4:26:08:020PM

CONVERT(CHAR(26), CURRENT_TIMESTAMP, 9)

10

02-22-06

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 10)

11

06/02/22

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 11)

12

060222

CONVERT(CHAR(6), CURRENT_TIMESTAMP, 12)

13

22 Feb 2006 16:26:08:020

CONVERT(CHAR(24), CURRENT_TIMESTAMP, 13)

14

16:26:08:037

CONVERT(CHAR(12), CURRENT_TIMESTAMP, 14)

20

2006-02-22 16:26:08

CONVERT(CHAR(19), CURRENT_TIMESTAMP, 20)

21

2006-02-22 16:26:08.037

CONVERT(CHAR(23), CURRENT_TIMESTAMP, 21)

22

02/22/06 4:26:08 PM

CONVERT(CHAR(20), CURRENT_TIMESTAMP, 22)

23

2006-02-22

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 23)

24

16:26:08

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 24)

25

2006-02-22 16:26:08.037

CONVERT(CHAR(23), CURRENT_TIMESTAMP, 25)

100

Feb 22 2006 4:26PM

CONVERT(CHAR(19), CURRENT_TIMESTAMP, 100)

101

02/22/2006

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 101)

102

2006.02.22

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 102)

103

22/02/2006

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 103)

104

22.02.2006

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 104)

105

22-02-2006

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 105)

106

22 Feb 2006

CONVERT(CHAR(11), CURRENT_TIMESTAMP, 106)

107

Feb 22, 2006

CONVERT(CHAR(12), CURRENT_TIMESTAMP, 107)

108

16:26:08

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 108)

109

Feb 22 2006 4:26:08:067PM

CONVERT(CHAR(26), CURRENT_TIMESTAMP, 109)

110

02-22-2006

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 110)

111

2006/02/22

CONVERT(CHAR(10), CURRENT_TIMESTAMP, 111)

112

20060222

CONVERT(CHAR(8), CURRENT_TIMESTAMP, 112)

113

22 Feb 2006 16:26:08:067

CONVERT(CHAR(24), CURRENT_TIMESTAMP, 113)

114

16:26:08:067

CONVERT(CHAR(12), CURRENT_TIMESTAMP, 114)

120

2006-02-22 16:26:08

CONVERT(CHAR(19), CURRENT_TIMESTAMP, 120)

121

2006-02-22 16:26:08.080

CONVERT(CHAR(23), CURRENT_TIMESTAMP, 121)

126

2006-02-22T16:26:08.080

CONVERT(CHAR(23), CURRENT_TIMESTAMP, 126)

127

2006-02-22T16:26:08.080

CONVERT(CHAR(23), CURRENT_TIMESTAMP, 127)

130

24 ???? 1427 4:26:08:080PM

CONVERT(CHAR(32), CURRENT_TIMESTAMP, 130)

131

24/01/1427 4:26:08:080PM

CONVERT(CHAR(25), CURRENT_TIMESTAMP, 131)

 

 

반응형

'Database > MSsql' 카테고리의 다른 글

[MSSQL] DATEDIFF ( datepart , startdate , enddate )  (0) 2014.08.29
[MSSQL] AUTOINCREMENT 설정하기  (739) 2013.10.17
MSSQL AUTO INCREMENT INIT  (57) 2013.07.04
[MSSQL] Database 복원  (0) 2013.05.07

DBCC CHECKIDENT ('WORK_INFORMATION', RESEED, 0)

반응형

'Database > MSsql' 카테고리의 다른 글

[MSSQL] DATEDIFF ( datepart , startdate , enddate )  (0) 2014.08.29
[MSSQL] AUTOINCREMENT 설정하기  (739) 2013.10.17
MS-SQL DATETIME CONVERT  (59) 2013.08.29
[MSSQL] Database 복원  (0) 2013.05.07







반응형

'Database > MSsql' 카테고리의 다른 글

[MSSQL] DATEDIFF ( datepart , startdate , enddate )  (0) 2014.08.29
[MSSQL] AUTOINCREMENT 설정하기  (739) 2013.10.17
MS-SQL DATETIME CONVERT  (59) 2013.08.29
MSSQL AUTO INCREMENT INIT  (57) 2013.07.04

+ Recent posts