Pages

Thursday, October 27, 2011

How to insert and retrieve datetime data type field in MS SQL Server 05 as ‘dd/mm/yyyy’ date format:





--Create a table in MS SQl server for the demo:
create table test_date
(
--Creating a auto increment column for primary key:
test_id bigint identity(1,1) not null primary key,

--Now creating a column which holds the date values form the input:
holiday datetime

)
--Provide input to the created table in ‘dd/mm/yyyy’ date format:
insert into test_date values(convert(datetime,'28/10/2011',103))

--Select inserted date value in required ‘dd/mm/yyyy’ date format:
select convert(varchar,holiday,103) as [Date in dd/mm/yyy format ] from test_date


You can also perform various operations on date format with the help of following link:









No comments:

Post a Comment