Wednesday, November 19, 2014

Konversi Tanggal di SQL SERVER

declare @periode as varchar(8),@periode_date as date
set @periode = '20141031'
set @periode_date ='2014-10-31'
select CONVERT(date,@periode) as HASIL
SELECT CONVERT(CHAR(10),@periode_date,110)  as HASIL
union all
SELECT CONVERT(CHAR(10),@periode_date,111)  
union all
SELECT CONVERT(CHAR(10),@periode_date,112)
union all
SELECT CONVERT(CHAR(15),@periode_date,113)  
union all
SELECT CONVERT(CHAR(15),@periode_date,109)
union all
SELECT CONVERT(CHAR(15),@periode_date,107)
union all
SELECT CONVERT(CHAR(15),@periode_date,106)
union all
SELECT CONVERT(CHAR(15),@periode_date,105)
union all
SELECT CONVERT(CHAR(15),@periode_date,104)
union all
SELECT CONVERT(CHAR(15),@periode_date,103)
union all
SELECT CONVERT(CHAR(15),@periode_date,102)
union all
SELECT CONVERT(CHAR(15),@periode_date,101)
union all
SELECT CONVERT(CHAR(15),@periode_date,100) 
Export to Excel General Format 
 
select cast(convert(decimal(12,0),convert(datetime,periode) + 2) 

Hasilnya :

Selamat Mencoba :)

No comments:

Post a Comment