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 > Data Access, Manipulation & Batch Languages > ANSI SQL > Date problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-27-03, 04:37
sqlboy sqlboy is offline
Registered User
 
Join Date: Mar 2003
Location: Memphis, TN, USA
Posts: 61
Post Date problem

Hi there !
Can anyone tell me how to convert 1900-01-01 00:00:00 into current date and current time. ?

I am just one the beginer of MSSQL and ASP. I have a table name annouce which work fine before i altered it. I added one new field named tdate whcih has datetype smalldatetime & have default value getdate().

When not provide the any value when inserting a new row, I got the error "Column name or number of supplied values does not match table definition. " which is true because the number of supplied value is 1 less then number of column. But then what does the default value meant for ?

When i provide NULL means( " ") then it automatically add the above mention date and time. ?

Can anyone put some light why it happend ? Shall, i have to put all the fields name except the new added field ? or i have to do something else.

With Thanks
Reply With Quote
  #2 (permalink)  
Old 09-27-03, 08:21
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
when you got that error message, it was most likely because you did not specify a column list for the INSERT statement

let's say your table has five fields, and you add a sixth one

in order for the default getdate() value to work, you have to say
Code:
insert
  into annouce
     ( fld1, fld2, fld3, fld4, fld5 )
values
     ( 1, 2, 3, 4, 5 )
this way the number of supplied values equals the number of columns you are inserting into

the column you did not mention in the insert statement is then given its default value

rudy
http://r937.com/
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