문제

I want to convert date which is string and like mm/dd/yy to date datatype in format yyyy/mm/dd.

도움이 되었습니까?

해결책

I would double cast it, once to datetime, then back to varchar.

select convert(varchar,convert(datetime,'12/14/2012'),101)

This works on SQL Server, but I don't have a Sybase instance to test on.

Edit: Looks like you could also use this:

select convert(varchar,date('12/14/2012'),101)

다른 팁

You have to first add a date field to your table:

alter table *your_table* add *newdate* as date;

Then you can convert using:

update *your_table* set *newdate* = cast(*your_string_date* as date);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top