How to insert system date in SQL Server 2008
First create table :
1) create table Test(id int identity(1,1),name varchar(20),V_DATE datetime)
use getDate() function :
insert into Test(name,vDate) values('Sw',getDate())
select * from Test
Output :
1 Nihar NULL
2 Rohan NULL
3 Rohan NULL
4 Sw 2012-05-30 15:57:35.230
Different Date & time Fornat read this :
select id,name,CONVERT(varchar,vDate,104) from Test --Date : 30.05.2012
select id,name,CONVERT(varchar,vDate,1) from Test --Date : 05/30/12
select id,name,CONVERT(varchar,vDate,2) from Test --Date : 12.05.30
select id,name,CONVERT(varchar,vDate,3) from Test --Date : 30/05/12
select id,name,CONVERT(varchar,vDate,4) from Test --Date : 30.05.12
select id,name,CONVERT(varchar,vDate,0) from Test --Date : May 30 2012 3:57PM
select id,name,CONVERT(varchar,vDate,5) from Test --Date : 30-05-12
select id,name,CONVERT(varchar,vDate,6) from Test --Date : 30 May 12
select id,name,CONVERT(varchar,vDate,7) from Test --Date : May 30, 12
select id,name,CONVERT(varchar,vDate) from Test --Date : May 30 2012 3:57PM
select id,name,CONVERT(varchar,vDate,8) from Test -- Time : 15:57:35
select id,name,CONVERT(varchar,vDate,9) from Test --Date : May 30 2012 3:57:35:230PM
Try it :
For More info. Click on label
1) create table Test(id int identity(1,1),name varchar(20),V_DATE datetime)
use getDate() function :
insert into Test(name,vDate) values('Sw',getDate())
select * from Test
Output :
1 Nihar NULL
2 Rohan NULL
3 Rohan NULL
4 Sw 2012-05-30 15:57:35.230
Different Date & time Fornat read this :
select id,name,CONVERT(varchar,vDate,104) from Test --Date : 30.05.2012
select id,name,CONVERT(varchar,vDate,1) from Test --Date : 05/30/12
select id,name,CONVERT(varchar,vDate,2) from Test --Date : 12.05.30
select id,name,CONVERT(varchar,vDate,3) from Test --Date : 30/05/12
select id,name,CONVERT(varchar,vDate,4) from Test --Date : 30.05.12
select id,name,CONVERT(varchar,vDate,0) from Test --Date : May 30 2012 3:57PM
select id,name,CONVERT(varchar,vDate,5) from Test --Date : 30-05-12
select id,name,CONVERT(varchar,vDate,6) from Test --Date : 30 May 12
select id,name,CONVERT(varchar,vDate,7) from Test --Date : May 30, 12
select id,name,CONVERT(varchar,vDate) from Test --Date : May 30 2012 3:57PM
select id,name,CONVERT(varchar,vDate,8) from Test -- Time : 15:57:35
select id,name,CONVERT(varchar,vDate,9) from Test --Date : May 30 2012 3:57:35:230PM
Try it :
SELECT CURRENT_TIMESTAMP
GO
SELECT {fn NOW()}
GO
SELECT GETDATE()
GO
For More info. Click on label
Comments
Post a Comment