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!

Convert text to date.

Status
Not open for further replies.

dweebe

Technical User
Jun 27, 2006
1
US
I'm a level test analyst and am trying to figure out an sql.

I have one column (called MOD_NUMBER) that has four characters. From that I need to take the last two digits and make them the year of a date string. For example if the MOD_NUMBER is 8310, the date needs to be 01-01-2010 00:00:00. If the MOD_NUMBER is 9902, the date needs to be 01-01-2002 00:00:00.


This is my SQL and I can't any way to get it to work:

select
dateadd('yy',substr(t1.MOD_NUMBER, 3, 2) as USPS_START_DATE,'01-01-2000 00:00:00')
from
M_VEHICLE_MODIFICATION t1

What am I doing wrong?

 
assuming you're on SQL Server,
Code:
select dateadd(year
              ,substr(t1.MOD_NUMBER,3,2) 
              ,'01-01-2000 00:00:00')
           as USPS_START_DATE
  from M_VEHICLE_MODIFICATION t1

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top