Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUBSTRING(DocDate, 7, 4)? 1

Status
Not open for further replies.

sk8ology

IS-IT--Management
May 14, 2004
64
US
I'm trying to create a SourceID that's the CompanySourceID '-'(just the year of a date with the format mm/dd/yyyy)'-' RefNum so it might look like this;

SourceID
asdf-2008-1234

UPDATE Docs
SET SourceID = CompanySourceID + '-' + SUBSTRING(DocDate, 7, 4) + RefNum

I get "Argument data type datetime is invalid for argument 1 of substring function."

I know the above query is probably way off. Your help would be greatly appreciated.
 
try...

Code:
UPDATE Docs
SET SourceID = CompanySourceID + '-' + Convert(VarChar(4), Year(DocDate)) + '-' + RefNum

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top