-7

I want to have date and time columns in my database. I chose DATE type for date but to only get time which type should I give and while writing a record for it in which format should I write?

Edit: I am using SQL Server.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Figen Güngör
  • 12,169
  • 14
  • 66
  • 108
  • Which database, Oracle, Mysql, SQL Server, something else? – A. Gilfrin Dec 21 '12 at 14:55
  • DATETIME instead of DATE – GeorgesD Dec 21 '12 at 14:56
  • Go with `ISO` for your dbms. [check out](http://msdn.microsoft.com/en-us/library/aa259188%28SQL.80%29.aspx) – bonCodigo Dec 21 '12 at 14:59
  • @user1463542 SQl server? or TSQL? – bonCodigo Dec 21 '12 at 15:00
  • [Here is another post](http://stackoverflow.com/questions/5287427/how-to-insert-datetime-into-the-sql-database-table) if this answers, please close the question. – bonCodigo Dec 21 '12 at 15:05
  • There is no DATETIME data type in Sql. I am gonna enter the time manually so I want to learn which datatype i should use for time while I create my table. – Figen Güngör Dec 21 '12 at 15:11
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21523/discussion-between-user1463542-and-boncodigo) – Figen Güngör Dec 21 '12 at 15:14
  • 1
    SQL just stands for "Structured Query Language", a definition of how you can communicate with relational databases. Your issue right now is with the database management system you're using, if you're using Microsoft SQL Server, there is definitely a datetime. What management system are you using, exact name/version etc? Data types can vary based on the system, and still be SQL. – Corey Dec 21 '12 at 15:17
  • http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html – Corey Dec 21 '12 at 15:40

1 Answers1

2

Try DateTime, contains both a date and time component.

http://msdn.microsoft.com/en-us/library/ms187819.aspx

EDIT: Now that you say you're using Oracle, it does have time support in the Date value it seems, though I'm not an oracle expert. I found this if it helps: http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html

Corey
  • 398
  • 1
  • 4
  • 18
  • There are comments above, where many **have suggested the same!** Like GeorgesD's comment etc. – bonCodigo Dec 21 '12 at 15:06
  • Yeah, it's a very basic question that three seconds of googling could answer if you didn't know SQL. Any reason to just comment vs. answer? I was just trying to help close out the question. – Corey Dec 21 '12 at 15:09