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

What is the difference Between Sql-server 2000 & 2005

3 Answers   Value Labs, Wipro,


How to configure and test odbc dsn settings?

0 Answers  


How to Check Whether a Global Temporary Exists in a SQL Database or not?

2 Answers  


What is the difference between rank and dense_rank?

0 Answers  


What is the difference between referencing and joining?

1 Answers  






What is the difference between function and stored procedure in sql server?

0 Answers  


What is a document index?

0 Answers  


Can I recover a damaged SQL Server 2008 database with the undamaged .mdb and .ldf files?

3 Answers   Apple,


What is pessimistic concurrency?

0 Answers  


Write a SQL query to make a column as unique?

0 Answers   Cap Gemini,


What is enhanced database mirroring in sql server 2008?

0 Answers  


What is the use of partition by in sql server?

0 Answers  


Categories