วันที่ภาษาไทย เต็มๆ (T-SQL) เอาไปประยุกต์เป็น Function ภายหลังได้

Select 'วัน'+  Case DatePart(dw,getdate())
     when 1 then 'อาทิตย์'
     when 2 then 'จันทร์'when 3 then 'อังคาร'
     when 4 then 'พุธ'when 5 then 'พฤหัสบดี'
     when 6 then 'ศุกร์'when 7 then 'เสาร์'
     end
+ ' ที่ '+  str(DatePart(dd,getdate()),4,0) 
+ space(2)+case datePart(mm,getdate())
     When 1 then 'มกราคม'
     When 2 then 'กุมภาพันธ์'
     When 3 then 'มีนาคม'
     When 4 then 'เมษายน'
     When 5 then 'พฤษภาคม'
     When 6 then 'มิถุนายน'
     When 7 then 'กรกฎาคม'
     When 8 then 'สิงหาคม'
     When 9 then 'กันยายน'
     When 10 then 'ตุลาคม'
     When 11 then 'พฤศจิกายน'
     When 12 then 'ธันวาคม'
end    
+ ' พ.ศ. '
+ str(DatePart(yy,getdate())+543,4,0)  as  [วันที่ภาษาไทย]

 

About the author