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
 Old Forums
 CLOSED - General SQL Server
 "left" function changing my datetime format ??

Author  Topic 

johnjasper
Starting Member

4 Posts

Posted - 2007-03-01 : 10:51:16
Here is a record in my table, the field is called "birthdate"

1948-02-27 00:00:00.000

When I do left(birthdate,4) I get back something like this:

Feb

How can I extract the year (1948) from this and why doesn't it come out correctly from my code ?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-01 : 10:58:42
when you use left(), the date is implicitly convert to string and for your case, it is implicitly convert to Feb 27, 1948

If you need the year :
select year(birthdate)


KH

Go to Top of Page

johnjasper
Starting Member

4 Posts

Posted - 2007-03-01 : 11:04:27
Thank You
Go to Top of Page
   

- Advertisement -