Date conversion problem  | Expert | | Join Date: Jul 2008 Location: Utrecht, The Netherlands
Posts: 283
| |
Hi,
I'm trying to insert some data in a table in SQL Server 2005, including a date. When I insert 29-07-2008 in the datetime field, it saves it as 25-7-1894 0:00:00. Can anyone tell me why it's doing that? The complete query is as follows: - INSERT INTO tblBCelLymfomen (BepalingID, BCelLymfomenDatumUitslag, BCelLymfomenKwaliteitBepaling, BCelLymfomenKwaliteitDNA, BCelLymfomenUitslag, BCelLymfomenConclusie, BCelLymfomenConclusie2, IgHAOnverdundGrootte, IgHBOnverdundGrootte, IgHCOnverdundGrootte, IgHDOnverdundGrootte, IgHEOnverdundGrootte, IgKappaAOnverdundGrootte, IgHAOnverdundBeschr, IgHBOnverdundBeschr, IgHCOnverdundBeschr, IgHDOnverdundBeschr, IgHEOnverdundBeschr, IgKappaAOnverdundBeschr, IgKappaBOnverdundGrootte, IgLambdaAOnverdundGrootte, IgKappaBOnverdundBeschr, IgLambdaAOnverdundBeschr) VALUES (1796, CONVERT(datetime, 29-07-2008, 120), '-', '-', 'Tests', '-', 'Tests', '1', '2', '3', '4', '5', '6', 'G', 'P', 'P(w)', 'R', 'R/P', 'Rw', '7', '8', 'Rw/P', 'D')
Thnx,
Steven
|  | Needs Regular Fix | | Join Date: Jan 2008 Location: South Africa
Posts: 361
| | | re: Date conversion problem
are u using a DateTimePicker as the control
|  | Expert | | Join Date: Jul 2008 Location: Utrecht, The Netherlands
Posts: 283
| | | re: Date conversion problem Quote:
Originally Posted by OuTCasT are u using a DateTimePicker as the control No, the data is coming from an Access 2003 database. I tried using both the raw data from the database and a DateTime-datatype.
Steven
|  | Expert | | Join Date: Jan 2008 Location: Sydney
Posts: 790
| | | re: Date conversion problem
Try changing this -
CONVERT(datetime, 29-07-2008
-
to this -
CONVERT(datetime, '29-07-2008'
-
or this -
CONVERT(datetime, #29-07-2008#
-
I'm thinking 29-07-2008 might be getting read as
29 minus 7 minus 2008 = -1986
25-7-1894 0:00:00 looks an awful lot like what happens when you save a number to a date field. The beginning of time according to microsoft is midnight on 01-01-1900
and i bet that date -1986 days (5.5 years) = 25-7-1894
|  | Expert | | Join Date: Jul 2008 Location: Utrecht, The Netherlands
Posts: 283
| | | re: Date conversion problem Quote:
Originally Posted by Delerna Try changing this -
CONVERT(datetime, 29-07-2008
-
to this -
CONVERT(datetime, '29-07-2008'
-
or this -
CONVERT(datetime, #29-07-2008#
-
I'm thinking 29-07-2008 might be getting read as
29 minus 7 minus 2008 = -1986
25-7-1894 0:00:00 looks an awful lot like what happens when you save a number to a date field. The beginning of time according to microsoft is midnight on 01-01-1900
and i bet that date -1986 days (5.5 years) = 25-7-1894 The quotes worked. Thnx! :)
|  | Similar Microsoft SQL Server bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,501 network members.
|