Reply
What is the correct way of inserting a DATE in to a database?
Old 08-03-2006, 11:18 AM What is the correct way of inserting a DATE in to a database?
Super Talker

Posts: 140
Code:
create table EMPLOYEE (
    FNAME varchar(20) NOT NULL,
    MINIT varchar(1) NOT NULL,
    LNAME varchar(20) NOT NULL,
    SSN varchar(9) primary key,    
    BDATE date NOT NULL,
    CITY varchar(15) NOT NULL,
    SEX varchar(1) NOT NULL,
    SALARY int NOT NULL, 
    SUPERSSN varchar(9),
    DNO varchar(1),
)

insert into EMPLOYEE values ('John','B','Smith','123456789',1965-09-01,'Houston','M',30000,'333444555','5');

When i try to execute the above code it says

Server: Msg 2715, Level 16, State 7, Line 4
Column or parameter #5: Cannot find data type date.

Please help me with this.

Thanks
nvidura is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-03-2006, 11:56 AM Re: What is the correct way of inserting a DATE in to a database?
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
You need to put your date in quotes when inserting. I'm assuming you're using the MySql database engine.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 08-03-2006, 04:42 PM Re: What is the correct way of inserting a DATE in to a database?
Super Talker

Posts: 140
Thanks
I've change the "date" datatype with "datetime"
it was a syntax error.
nvidura is offline
Reply With Quote
View Public Profile
 
Old 08-04-2006, 08:19 AM Re: What is the correct way of inserting a DATE in to a database?
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Always specify the DB or the Language in which you facing the problem.
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Reply     « Reply to What is the correct way of inserting a DATE in to a database?
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12027 seconds with 12 queries