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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL select query 1

Status
Not open for further replies.

RosieGp

Programmer
Jun 23, 2009
83
US
Ok in my Employee_YearsOfWork table... I have the following:
Employees_YearsOfWork
ID Years Date_Completed
1-1 2 Dec - 12
12-2 7 June - 15
12-5 15 Aug - 11
I have to just display Date_Completed as following:
Employees_YearsOfWork
ID Years Date_Completed
1-1 2 12
12-2 7 15
12-5 15 11

How do I trim everything before the 12 or 15 or 11...
My query:

Select ID, Years, Date_Completed
From Employees_YearsOfWork

Thanks in advance for your help...

 
Assuming the number part always comes after - and a space, try
Code:
select Date_Completed, substring(Date_Completed,charindex('- ',Date_Completed) + 2, len(Date_Completed)) as NumberOnlyPart
froom Employees_YearsOfWork

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top