Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MS SQL - date field?

Author  Topic 

jarv
Posting Yak Master

131 Posts

Posted - 2007-08-04 : 14:35:33
I have set my record rsAge to a datetime and set default value to (getdate()) I want to fill in a date of birth, when i try this with something like 08/11/78 it just comes back with: 01/01/1900 00:00:00

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-04 : 15:02:08
show us your code.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

nirene
Yak Posting Veteran

98 Posts

Posted - 2007-08-04 : 21:34:58
insert into Table values ('1978/11/08')

When selected it will return 08/11/1978
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-08-04 : 21:49:39
1 jan 1900 is a date of 0 so you are inserting 0 into the column.
The default will only be used if the column is not part of the insert - i.e. not 0 or null but not included in the statement.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2007-08-05 : 15:20:16
but i am putting 08/11/78 into the formfield?!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-05 : 15:51:13
are you using parameters or are you still contencating SQL strings?

if you're not using parameteres you'll have to format your posted value to yyyymmdd format and pass that to the db.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jarv
Posting Yak Master

131 Posts

Posted - 2007-08-06 : 08:50:16
I just put SET DATEFORMAT dmy in the SQL string that didn't work?!
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-08-06 : 11:46:14
Use the profiler to see what is being sent to the server - you'll probably find it's 0.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -