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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Date Problems

Author  Topic 

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 12:24:36
Why does this work

DECLARE @d datetime; SET @d = '2/3/1978'
SELECT @d
SELECT ISDATE('2/3/1978')

And this doesn't?

SELECT convert(date,'2/3/1978',1)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 12:35:24
It does not seem to like the style you have commanded (1= without century).

However, it does no balk at the following:


SELECT CONVERT(DATE,'2/3/1978',101)
SELECT CONVERT(DATE,'2/3/78',1)

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 12:43:30
Thanks Jay

The guy I'm helping is placing date data in a varchar field

And yet this works

DECLARE @d datetime; SET @d = '2/3/78'
SELECT @d

Jim: Since you can't change the column, you need a better mask on the input




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 12:49:21
Sure thing Brett,

Nice to see you around and still helping others so generously.

Have a good one.

-Jay
Go to Top of Page
   

- Advertisement -