ADS обеспечивает несколько ограниченную функциональность обработки даты. Кажется, что самый простой формат даты - YYYY-MM-DD
, но преобразование из ваших столбцов в дату, которую вы ищете, несколько запутано.
Вот пример, который должен помочь вам разобраться.
create table #temp (calyear numeric(4, 0), calmonth numeric(2,0));
insert into #temp (calyear, calmonth) values (2017, 10);
insert into #temp (calyear, calmonth) values (2017, 7);
/*
Start convoluted workaround here. Cast the result of the concatenation below
(which creates a string in the format 'YYYY-MM-DD') into a date value
*/
select cast(txtdate as SQL_DATE) as newdate from
(
/*
Concatenate year, month (adding leading zero if needed to make two-digit)
and month
*/
select
trim(cast(calyear as SQL_Char)) + '-' +
right('00' + trim(cast(calmonth as SQL_Char)), 2) +
'-01' as txtdate from #temp
) t;