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

Date Problem 3

Status
Not open for further replies.

charbrad

Technical User
Nov 7, 2002
132
US
I have a column within a table that is pulling the date, folder and file name as:
Code:
#2007\12\12\15\DOCFILE1.TXT

Is there a way to convert this in SQL to get just the date?
Code:
[b]2007\12\12[/b]
 
Code:
SELECT CONVERT(Datetime, REPLACE(SUBSTRING(YourField,2,8),'/',''))
FROM YourTable
not tested

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
Use the [!]SubString[/!] function

[tt][blue]Select SubString(ColumnName, 2, 10) As TheDate[/blue][/tt]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Oops, I used the wrong slash :)
Code:
SELECT CONVERT(Datetime, REPLACE(SUBSTRING(YourField,2,8),'\',''))
FROM YourTable


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
8 ?

Are you sure? [smile]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
How about another flavor?
Code:
Select Right(Left(YourField, 11),10)
      From YourTable
 
No!!!!!
I am not :)
I don't know why my math is not working today :
4+2+2+2 = 8 ???????????????????????
Thank God I don't count money I should get that way :)
If I should give, that is another question :)

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
Microsoft MVP VFP
 
I used 10 in place of 8....worked like a charm. Have a star!
 
Boris,

You are too cool. Keep up the good work.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Boris,

There's nothing wrong with 8!

Code:
SELECT CONVERT(Datetime, SUBSTRING(REPLACE(YourField,'\',''),2,8))
FROM YourTable
 
Timing is everything. [wink]

-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