Sqlserver commonly used functions

Bulk edit date format is 'YYYY-MM-DD'

update table set date field = Case  When  The ISDATE (date field) = . 1  the then  the substring ( Convert ( VARCHAR ( 100 ), Convert ( datetime , date fields, 120 ), 23 is ), 0 , . 11 ) the else date field end

Date format is "YYYY-MM" string, add or subtract month

Date field = the SUBSTRING ( the CONVERT ( VARCHAR ( 100 ), the DATEADD ( month The , - . 1 , the CONVERT ( datetime , (Date field + ' -01 ' ), 120 )), 23 ), 0 , 8 ))

 

Guess you like

Origin www.cnblogs.com/dangpengfei/p/11091463.html