October 19, 2004 at 4:32 am
Hello,
Whenever i try to run the following SQL the date is always not what's input but 01/01/1900,
insert into t_postCard(Source, toName, toEmail, fromName, fromEmail, message, readRecept, flash, dateSent, pass) values('postCard1', 'dfsd', 'sdgfgfsd@fdgd.com', 'fdsag', 'dgfd@dfga.com', 'fsfd', 0, 1, 19/10/2004 11:14:43, 7824)
can anyone offer any help?
October 19, 2004 at 5:23 am
I would try putting single quotes around your date/time. The system is probably interpreting your statement mathematically and not recognizing it as a date/time.
Good Hunting!
AJ Ahrens
webmaster@kritter.net
October 19, 2004 at 6:28 am
I would do a AJ suggests, but the reason for it is that when a datetime value is being inputted, it's being inputted as a string and SQL Server implicitly converts it to DATETIME datatype.
Also, start your insert with this:
SET DATEFORMAT dmy
That will ensure that SQL Server interprets the date in the proper format.
-SQLBill
October 20, 2004 at 2:46 am
SET DATEFORMAT dmy
is an option.
You can as well change your date format to ANSI
i.e. 19/10/2004 becomes '20041019'
SQL server converts this to date irrespective of the date format at database end.
October 20, 2004 at 4:43 am
Hi Orkei,
I think whereever u got the value as '01/01/1900'. you might have inserted blank value('') in database.When u try to insert blank value ('') in a column of Data type Date it will store '01/01/1900' in that column .To avoid this replace Blank '' with NULL.
For conversion use case statement or replace statement.
Thanks
Yuvraj
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy