How can u convert the Date to String?

Answers were Sorted based on User's Feedback



How can u convert the Date to String?..

Answer / rajesh ranjan

select cast(getdate() as varchar)

select convert(varchar,getdate(),101)-mm/dd/yyyy
select convert(varchar,getdate(),102)-yy.mm.dd
select convert(varchar,getdate(),106)-ddmmyy
select convert(varchar,getdate(),108)-hh:mm:ss

etc.

Is This Answer Correct ?    18 Yes 2 No

How can u convert the Date to String?..

Answer / prasad

select convert(varchar,columnname,101) from tablename

Is This Answer Correct ?    11 Yes 2 No

How can u convert the Date to String?..

Answer / anil singh

iN PL/SQL WE USE TO_CHAR FUNCTION
SELECT TO_CHAR(SYSDATE,'MI','HH:MM:SS' FROM TABLE NAME

Is This Answer Correct ?    4 Yes 2 No

How can u convert the Date to String?..

Answer / samba shiva reddy . m

SELECT
GETDATE() AS UnconvertedDateTime,
CAST(GETDATE() AS nvarchar(30)) AS UsingCast,
CONVERT(nvarchar(30), GETDATE(), 126) AS UsingConvertTo_ISO8601 ;
GO
this will work for u try it out.

Is This Answer Correct ?    2 Yes 1 No

How can u convert the Date to String?..

Answer / sivakumar

Select convert(varchar(20),getdate()) As Date

Is This Answer Correct ?    5 Yes 5 No

How can u convert the Date to String?..

Answer / deepak rohilla

select convert(varchar(20),getdate())

Is This Answer Correct ?    5 Yes 9 No

Post New Answer

More SQL Server Interview Questions

Explain timestamp datatype?

0 Answers  


write query for fourth maximum salary from employee table

14 Answers   Mind Tree, SP Software,


Which tcp/ip port does the sql server run on? How can it be changed?

0 Answers  


Can we add our custom code in ssis?

0 Answers  


Why transaction is important?

0 Answers  






What do you understand by check constraint in sql server?

0 Answers  


Which stored procedure will you be running to add a linked server?

1 Answers  


What is service broker?

0 Answers  


Explain about extended stored procedure?

0 Answers  


How to Create Login and User through query in Sql server 2005.and also how to delete Login and User through query?

2 Answers  


Can we join two tables without primary key?

0 Answers  


What is a not null constraint?

0 Answers  


Categories