GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Database  >  SQL Server
Go To First  |  Previous Question  |  Next Question 
 SQL Server  |  Question 35 of 99    Print  
What is the code to create a table having a column named DATE, which takes date in the format dd/mm/yyyy, in SQL Server2000? Or any format of date.

  
Total Answers and Comments: 3 Last Update: June 27, 2006     Asked by: rajivkapoor 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 12, 2006 06:08:27   #1  
sudal2000 Member Since: May 2006   Contribution: 2    

RE: What is the code to create a table having a column...

hai

using this query you can take as you like

select convert(varchar DATE 107) from tablename

DATE->one of the column is availabe in table which is created by you


 
Is this answer useful? Yes | No
June 24, 2006 00:01:05   #2  
rick        

RE: What is the code to create a table having a column...

CREATE TABLE mytable ([Date] SMALLDATETIME)


 
Is this answer useful? Yes | No
June 27, 2006 02:07:10   #3  
Yogesh Srivastava        

RE: What is the code to create a table having a column...

Hi

Your can try this

SELECT CONVERT(varchar GETDATE() 103)

In this example the GETDATE() will return your sql server system date.

and the CONVERT is used to convert the date into the desired fomat.

Basically the CONVERT requires three arguments

1. Datatype

2. Date to Convert

3. Format style

Here is the list of style .....

Style ID

Style Type

0 or 100 mon dd yyyy hh:miAM (or PM)
101mm/dd/yy
102yy.mm.dd
103dd/mm/yy
104dd.mm.yy
105dd-mm-yy
106dd mon yy
107Mon dd yy
108hh:mm:ss
9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM)
110mm-dd-yy
111yy/mm/dd
112yymmdd
13 or 113 dd mon yyyy hh:mm:ss:mmm(24h)
114hh:mi:ss:mmm(24h)
20 or 120 yyyy-mm-dd hh:mi:ss(24h)
21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h)
126yyyy-mm-dd Thh:mm:ss.mmm(no spaces)
130dd mon yyyy hh:mi:ss:mmmAM
131dd/mm/yy hh:mi:ss:mmmAM

Enjoy the Code...

Hope this will help u


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape