If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Date datatype

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-24-05, 08:13
parmy parmy is offline
Registered User
 
Join Date: Jan 2005
Posts: 18
Question Date datatype

Hi guys, i'm not new to sql, but its my first time using mysql. i am creating a new table and keep getting errors when trying to insert a date feild or time feild:

create table MessageBoard
(
MessageID char(10) not null,
MemberID char(10) not null,
Topic varchar(50) not null,
Description varchar(250) not null,
Expiry_Date date 'yyyy-mm-dd' not null,
Start_time time 'hh:mm:ss',
Date/Time timestamp 'yyyy-mm-dd hh:mm:ss' not null,

CONSTRAINT MessageBoard_pk
PRIMARY KEY (MessageID),
);

I keep getting a syntax error for the two date feilds and time feild? i havn't got a clue what i'm doing wrong? is inserting a date feild different in mysql to SQL server?

i'd appreciate any help plzzzz, thanks for your time...

Last edited by parmy; 01-24-05 at 08:21.
Reply With Quote
  #2 (permalink)  
Old 01-24-05, 10:51
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Those are the correct types, but you don't have to say anything more than date or timestamp. You can't specify yyyy-mm-dd since they are only accepted that way and don't accept other input.

You can use DATE_FORMAT when pulling your results to format the date or timestamp in various ways. See the manual for that.
Reply With Quote
  #3 (permalink)  
Old 01-24-05, 15:06
parmy parmy is offline
Registered User
 
Join Date: Jan 2005
Posts: 18
thanks

thanks 4 da advice
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On