2012-09-21

TSQL - Excel numeric date to SQL date

select

       40756 as ExcelDate
       , cast(dateadd(d, 40756, '1899-12-30') as date ) as TSQLDate
;

Excel dates are represented by numbers.
Decimals represent time... which is out of the scope of this post.
The trick is knowing that day 1 is for January 1st, 1900 (1900-01-01).


2012-09-06

TSQL - Position of the first strange character


select PATINDEX('%[^A-Za-z0-9 ]%' , 'as-df.qwer' );