Maash
Maash

Reputation: 31

Trimming characters from a column

I have a column like this

DATE

"112113"

"011414"

and so on..

I want to remove the first and last characters from the entire DATE column. ie) I want to get rid of these "".

Please help.

Upvotes: 0

Views: 152

Answers (4)

dustyhoppe
dustyhoppe

Reputation: 1813

Try this:

SELECT SUBSTRING(Date, 2,  LEN(Date) - 2) FROM TableName

You could then update the Date column as follows:

UPDATE TableName
    SET Date = SUBSTRING(Date, 2,  LEN(Date) - 2)

Upvotes: 0

Prashant
Prashant

Reputation: 2614

you can do in oracle as answer below

TRIM(BOTH CHR(34) FROM '"011414"')

Result: 011414

or you can use replace("011414",'"');

or you can use SUBSTRING function also.

as per your requirement..

Upvotes: 0

user275683
user275683

Reputation:

You can do it with SUBSTRING that is if you using TSQL.

 SUBSTRING(date, 2, LEN(date) - 2)

update: Had parenthesis in the wrong spot

Upvotes: 1

Jason McCreary
Jason McCreary

Reputation: 73031

Considering you are only removing the quotes, you might get away with REPLACE() which compatible with most relational database systems.

SELECT REPLACE(date, '"', '') FROM your_table;

Upvotes: 1

Related Questions