25 สิงหาคม 2558

ThaiLongDate Formula Field In Crystal Report

ตัวอย่าง Formula Field ที่ใช้แปลงวันที่ให้เป็นภาษาไทย ในรูปแบบ วัน เดือน ปี พ.ศ. (ตัวอย่าง 25 สิงหาคม 2558)


totext(day(PrintDate),0) + " " + (
if Month(PrintDate)=1 then "มกราคม" else
if Month(PrintDate)=2 then "กุมภาพันธ์" else
if Month(PrintDate)=3 then "มีนาคม" else
if Month(PrintDate)=4 then "เมษายน" else
if Month(PrintDate)=5 then "พฤษภาคม" else
if Month(PrintDate)=6 then "มิถุนายน" else
if Month(PrintDate)=7 then "กรกฎาคม" else
if Month(PrintDate)=8 then "สิงหาคม" else
if Month(PrintDate)=9 then "กันยายน" else
if Month(PrintDate)=10 then "ตุลาคม" else
if Month(PrintDate)=11 then "พฤศจิกายน" else
if Month(PrintDate)=12 then "ธันวาคม" else "")
+ " " + totext(if(Year(PrintDate)<2500) then Year(PrintDate)+543 else Year(PrintDate),0,"")

** อย่าลืม เปลี่ยน Font ให้เป็น Font ภาษาไทยด้วยนะครับ เช่น Angsana UPC หรือ Cordia UPC เพื่อจะได้มองเห็นอักขระภาษาไทยนะครับ****