 |
|
เรื่องวันที่ใน Crystal Report คศ เป็น พศ ครับ (ขออนุญาติลงไว้เผื่อผู้ที่ยังไม่รู้) |
|
 |
|
|
 |
 |
|
หลังจากที่ผมเองได้ประสบปัญหาเรื่องวันที่อยู่พักนึงในเรื่องของ Print Date ที่ทำยังไงก็ปรับไม่ได้สักทีก็เลยลองใช้ Code ที่ลงไว้ตามนี้เลยครับ
ใช้ Code นี้นะครับสำหรับผู้ที่ปรับไม่ได้
Code สำหรับ Print Date
cdate(Year(PrintDate)+543,Month(PrintDate),day(PrintDate))
Code สำหรับ Data Field
cdate(Year({bill_damage.dam_date})+543,Month({bill_damage.dam_date}),day({bill_damage.dam_date}))
'/// สีแดงคือ Data Field นะครับ
วิธีทำ Print Date
1. คลิกขวาที่ส่วนของ Formula Fields แล้วเลือก New
2. ตั้งชื่อเลยครับ แล้วกด Enter
3. ใส่ cdate(Year(PrintDate)+543,Month(PrintDate),day(PrintDate))
4. กดเซฟเลยครับ
วิธีทำ Data Field
1. ทำข้อที่ 1-2 ในแบบของ Print Date ครับ
2. ใส่
cdate(Year({bill_damage.dam_date})+543,Month({bill_damage.dam_date}),day({bill_damage.dam_date}))
4. กดเซฟเลยครับ
หมายเหตุ** Data Field สีแดง จะเปลี่ยนไปตาม Database ของใครของมันนะครับ และหวังว่าจะมีประโยชน์บ้างสำหรับผู้ที่ยังไม่รู้นะครับ
Tag : .NET, Crystal Report, VB.NET, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2011-01-24 09:56:15 |
By :
toekungs |
View :
34263 |
Reply :
31 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณอยากสุดซึ้ง ถ้าไม่ได้ความรู้นี้ พรุ่งนี้คงแย่แน่เลย ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2011-06-16 02:06:45 |
By :
artto81 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
+1 สำหรับความตั้งใจและนำใจงามครับ 
|
 |
 |
 |
 |
Date :
2011-06-16 08:43:45 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากคับ
|
 |
 |
 |
 |
Date :
2011-12-14 15:14:48 |
By :
Angie_mink |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
+1ครับ
|
 |
 |
 |
 |
Date :
2011-12-14 15:16:04 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเป็น Data Field เดียว 2012 ให้ได้เป็น 2555 ต้องเป็นแบบไหนครับ
|
 |
 |
 |
 |
Date :
2012-03-02 00:00:54 |
By :
โต้ง |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สุดยอดครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-03-12 00:28:33 |
By :
worajito |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
+1 ขอบคุณนะค่ะ
|
 |
 |
 |
 |
Date :
2012-03-12 08:47:49 |
By :
athaneekul |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-03-12 22:27:43 |
By :
day1989 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าเกิดว่าผมอยากเปลี่ยนในตอนเอามาแสดงใน Gridview กับ ใน Label ล่ะครับ ใช้โค้ดนี้ได้ป่ะ
หรือว่าต้องทำยังไงอ่ะครับ
|
ประวัติการแก้ไข 2012-05-31 15:20:06
 |
 |
 |
 |
Date :
2012-05-31 15:18:22 |
By :
KuNgbAng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีประโยชน์มากครับผมขอบคุณมากครับ
ไม่ทราบว่ามีกันหรือยังนะครับ พอดีได้นำ Code ของพี่ไปใช้แล้วแสดง PrintDate เป็นของไทยแล้ว คือ 24/1/2556
แต่ต้องการให้แสดงเป็น 24 มกราคม 2556 เลยนำมาประยุกต์กับ Code ที่มีอยุ่เลยได้ผลตามที่ต้องการดังนี้
Code
Local stringVar m;
m:= ToText(cdate(PrintDate),Month(PrintDate),day(PrintDate)),"dd/MM/yyyy");
local stringVar m2;
m2:= mid(m,4,2);
if m2="01" then
m2:="มกราคม"
else if m2="02" then
m2:="กุมภาพันธ์"
else if m2="03" then
m2:="มีนาคม"
else if m2="04" then
m2:="เมษายน"
else if m2="05" then
m2:="พฤษภาคม"
else if m2="06" then
m2:="มิถุนายน"
else if m2="07" then
m2:="กรกฏาคม"
else if m2="08" then
m2:="สิงหาคม"
else if m2="09" then
m2:="กันยายน"
else if m2="10" then
m2:="ตุลาคม"
else if m2="11" then
m2:="พฤษจิกายน"
else if m2="12" then
m2:="ธันวาคม";
(mid(m,1,2)) + " " + m2 + " " + ToText(ToNumber(mid(m,7,4))+543,"####",0);
ปล.ไม่ทราบว่าท่านอื่นมีวิธีที่ง่ายกว่านี้ไหมคับเพื่อ Code จะได้สั้นๆหน่อย
|
ประวัติการแก้ไข 2013-01-24 16:55:34 2013-01-24 16:56:09
 |
 |
 |
 |
Date :
2013-01-24 16:51:17 |
By :
cannon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากค่ะ   
|
 |
 |
 |
 |
Date :
2013-02-21 17:41:34 |
By :
JOY |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองทำตามโค้ดด้านบนแล้ว ใช้งานได้
แต่ติดตรง ถ้าเป็นวันที่ 29 กุมภา 2559 มันจะเกิด Error ไม่สามารถแสดงผลได้ครับ

มีใครเจอปัญหานี้ หรือรู้วิธีแก้บ้างมั้ยครับ?
ผมทำโปรเจคจบอยู่ ทำงานเกี่ยวกับวันที่เยอะมาก ใกล้จะส่งแล้ว
ขอความกรุณาด้วยครับ
|
ประวัติการแก้ไข 2013-04-11 09:55:52
 |
 |
 |
 |
Date :
2013-04-11 09:48:16 |
By :
Tsumine |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
 
ขอบพระคุณมากครับ
|
 |
 |
 |
 |
Date :
2015-05-22 18:34:53 |
By :
komkit |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนมไปอึกวิธีละกัน ถ้าเป็น SQL SERVER ใช้เยี่ยงนี้มันก็ได้นะ ไม่ต้องบวกอะไรมากมาย
แถมจะเอาชื่อวันเดือนแบบไทยก็ได้ จริงๆมันก็ได้ทุกภาษา
SELECT FORMAT(getdate(), 'ddd dd-MMM-yyyy', 'th-TH');
คือกับตัวทำรายงานอย่าง CR เนี่ยผมเองจะไไม่สนับสนุนให้ทำอะไรกับมันมาก
ให้มันทำหน้าที่แค่อกรายงานให้ก็พอ พวกคำนวณหรือ format อะไรนี่ควรจะทำเอง
เพราะมันเคยล่มมาหลายครั้งละ ซึ่งมีทั้งที่แก้เองได้ ต้องรอ patch
หนักหน่อยก็ต้องใช้โดนบังคับให้ซื้อตัวจริง จริงจะได้ support
(ตอนที่ seagate ขาย CR ให้ SAP ใหม่ๆนั่นแหละครัช bug งี้มาเป็นฟาร์ม)
เสริมนิสในทุก database ที่ค่อนข้างมาตรฐานเค้าจะเตรียมเรื่อง region format ไว้แล้วนะ
หาวิธีเรียกก็พอไม่เพฃหนื่อยอะไรมากมายครัช
|
 |
 |
 |
 |
Date :
2015-05-24 16:37:12 |
By :
DOG{B} |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัจจุบันใช้ MS SQL Server 2008 R2 มันไปอยู่ไหนหว่าฟังก์ชั่น FORMAT
|
 |
 |
 |
 |
Date :
2015-05-24 20:27:14 |
By :
... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนมไปอึกวิธีละกัน HACKS CRUFL
เขียนเอาไว้ตั้งนานนมก่อนที่จะรู้จักคำว่า Lampd/LINQ
Code (VB.NET)
Imports System.Runtime.InteropServices
<ComVisible(True), InterfaceType(ComInterfaceType.InterfaceIsDual), GuidAttribute("D5447A7B-FDD0-4869-8B12-69EB1A56E6E0")> _
Public Interface IEHacksCRUfl
Function NumberThai(ByVal strPass As String) As String 'แปลงตัวเลขอารบิคเป็นตัวเลขไทย เช่น 123 --> ๑๒๓
Function ThaiDate(ByVal dPass As DateTime, ByVal strFormat As String) As String 'for support era ไทย/คริสศักราช
Function BahtText(ByVal dblPass As Double) As String 'คำตัวเลขเป็นคำอ่านภาษาไทย เช่น 12.25 --> สิบสองบาทยี่สิบห้าสตางค์
End Interface
Code (VB.NET)
Imports System.Runtime.InteropServices
<ComVisible(True), ClassInterface(ClassInterfaceType.None), GuidAttribute("F2AFEC0E-B776-41a7-A4CD-CF7F09386AE5")> _
Public Class CRUFLWaroot : Implements IEHacksCRUfl
'
'แปลงตัวเลขอารบิค เป็นตัวเลขไทย เช่น 123 เป็น ๑๒๓ เป็นต้น
'
Public Function NumberThai(ByVal strPass As String) As String Implements IEHacksCRUfl.NumberThai
If String.IsNullOrEmpty(strPass) = True OrElse strPass.Trim.Length = 0 Then Return String.Empty
For iSub As Byte = 0 To 9 'Byte 1-255
strPass = strPass.Replace(iSub.ToString, Chr(iSub + 240)) 'อักษรตัวอื่นคงไว้ที่เดิม
Next
Return strPass
End Function
'
'กำหนดรูปแบบวันที่ในรายงาน Crystal Reports /Support Era ทั้งแบบ พุทธและคริสต์
'
Public Function ThaiDate(ByVal dPass As Date, ByVal strFormat As String) As String Implements IEHacksCRUfl.ThaiDate
Dim strSubValue As String = String.Empty
Try
strSubValue = String.Format(strFormat, dPass)
Catch ex As Exception
'Ignore error and return String.Empty
End Try
Return strSubValue
End Function
'
'แปลงตัวเลขเป็นคำอ่านภาษาไทย เช่น 101 -> หนึ่งร้อยหนึ่งบาทถ้วน
'
Function BahtText(ByVal dblPass As Double) As String Implements IEHacksCRUfl.BahtText
Dim dbSubMgr As New clsMy.DigitManager
Return dbSubMgr.BahtText(dblPass)
End Function
End Class
Code (VB.NET)
Public Class DigitManager
'
'อ่านตัวเลขเป็นคำอ่านภาษไทย เช่น 101 -> หนึ่งร้อยหนึ่งบาทถ้วน
'Lastupdate : 01/05/2005
'
Public Function BahtText(ByVal dblPassNumber As Double) As String
Return ThaiBahtText(dblPassNumber)
End Function
Private Function ThaiBahtText(ByVal strPriNumber As String) As String
Dim dblSubNumber As Double
If Not Double.TryParse(strPriNumber, Globalization.NumberStyles.AllowDecimalPoint Or _
Globalization.NumberStyles.AllowThousands Or Globalization.NumberStyles.AllowCurrencySymbol _
, Nothing, dblSubNumber) Then
Return "ตัวเลขไม่ถูกต้อง"
Exit Function
End If
Dim strSubNumValue As String = Format(dblSubNumber, "###0.00").ToString.PadLeft(15, Space(1)) 'เอาเครื่องหมายคั่นหลักพันออกให้หมด
Dim strSubThaiBaht As String = "" 'เก็บค่าการอ่านตัวเลขเป็นคำอ่านภาษาไทย
If Val(strSubNumValue) = 0 Then Return "ศูนย์บาท"
If strSubNumValue.Length > 15 Then Return "ตัวเลขเกินหลักแสนล้าน โปรแกรมสามารถอ่านได้ไม่เกินเก้าแสนเก้าหมื่นเก้าพันเก้าร้อยเก้าสิบเก้าล้านบาท"
'
strSubThaiBaht = IIf(Val(strSubNumValue.Substring(0, 6)) > 0, ThaiHundredThousand(strSubNumValue.Substring(0, 6)) & "ล้าน", "")
strSubThaiBaht &= ThaiHundredThousand(strSubNumValue.Substring(6, 6)) & IIf(Val(strSubNumValue) >= 1, "บาท", "")
strSubThaiBaht &= IIf(strSubNumValue.Substring(13, 2) = "00", "ถ้วน", ThaiHundredThousand(Space(4) & strSubNumValue.Substring(13, 2)) & "สตางค์ขะแมร์")
'
Return strSubThaiBaht
End Function
Private Function ThaiHundredThousand(ByVal strPassNum As String) As String
Dim arrSubCount() As String = {"", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า", ""}
Dim arrSubCountTen() As String = {"", "สิบ", "ยี่สิบ", "สามสิบ", "สี่สิบ", "ห้าสิบ", "หกสิบ", "เจ็ดสิบ", "แปดสิบ", "เก้าสิบ", ""}
Dim arrSubCountHund() As String = {"", "แสน", "หมื่น", "พัน", "ร้อย", "สิบ", ""}
Dim iSub, iSubNumVal As Byte '0,1,2,...,9 only
Dim strSubReturn As String = ""
For iSub = 1 To 6 'รอบแรกคือ หลักแสน รอบสุดท้ายคือ หลักหน่วย
iSubNumVal = Val(strPassNum.Substring(iSub - 1, 1)) 'split มาประมวลผลทีละตัวเท่านั้น ( 0,1,2,...,9)
strSubReturn &= IIf(iSubNumVal > 0, IIf(iSub = 6 AndAlso iSubNumVal = 1 AndAlso Val(strPassNum) > 1 _
AndAlso strPassNum.Substring(4, 1) <> "0", "เอ็ด", IIf(iSub <> 5, _
arrSubCount(iSubNumVal) & arrSubCountHund(iSub), arrSubCountTen(iSubNumVal))), "")
Next
Return strSubReturn 'Max(เก้าแสนเก้าหมื่นเก้าพันเก้าร้อยเก้าสิบเก้าบาท)
End Function
End Class
|
 |
 |
 |
 |
Date :
2015-05-24 21:00:25 |
By :
... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก #NO 24
แถมให้อีกนิดหนึ่ง Function NumberThai สมัยโน้น (เก่าเก็บ)
อันนี้ยุคสมัย
Code (VB.NET)
'ตัวอย่างการใช้งาน : Dim แก่เพราะอยู่นาน = New RegularExpressions.Regex("[0-9]").Replace("987654321", New RegularExpressions.MatchEvaluator(AddressOf NumberThai))
Private Function NumberThai(ByVal s As RegularExpressions.Match) As String
Return {"๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙"}(Integer.Parse(s.Value))
End Function
|
 |
 |
 |
 |
Date :
2015-05-24 21:15:03 |
By :
... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@ {Dog B ที่ไม่มีหาร}
จาก #NO 24 สมมุติว่าคุณมองภาพไม่ออก มันก็คล้ายฯ (อันเดียวกันนั่นแหละ CLR) บน SQL Server นั่นแหละครับ
|
 |
 |
 |
 |
Date :
2015-05-24 21:21:34 |
By :
... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอ้ย นี่มันเรื่อง thai date format นี่เนอะ ลืมๆ
Code (C#)
static void Main(string[] args)
{
double MoneyMoney = 123154546544.00;
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.WorksheetFunction xlFunction = xlApp.WorksheetFunction;
string MoneyStr = xlFunction.BahtText(MoneyMoney);
DateTime myDate = DateTime.Now;
string ThaiDateStr = xlFunction.Text(myDate, "[$-D07041E]วววว ดด ดดดด ปปปป");
System.Console.WriteLine("THAIDATE OF {0} IS {1}", myDate.ToString("dd-MM-yyyy"), ThaiDateStr);
System.Console.WriteLine("BATHTEXT OF {0} IS {1}", MoneyMoney, MoneyStr);
System.Console.ReadLine();
}
คือในตัว .net มันก็ convert ได้อยู่แล้ว แต่หากใช้ Excel จะเพิ่มการเปลี่ยนตัวเลขเป็นเลขไทยให้ด้วย
tip อยู่ที่ Flag ในการ covert >> [$-D07041E]
D >> เปลี่ยนเป็นเลขไทย ถ้าอยากคงอารบิกไว้ก็เอา D นี่ออก
07 >> เป็นปี Buddhist ไม่ใช่ Anno Domini >> ปี พศ. ไม่ใช่ คศ.
041E >> LCIDS ของภาษาไทยจ่ะ
ปล. ใช้ date format pattern ด้วยภาษาไทยได้ด้วยนะแจะ
|
 |
 |
 |
 |
Date :
2015-05-25 00:17:27 |
By :
DOG{B} |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@ {DOG B ที่ไม่มีหาร}
Code
ความสนุกของ programming คือมันเขียนได้หลายแบบ
คุณพูดได้ถูกต้องแล้วครับและคุณไม่ได้ใช้ปากเขียนโปรแกรมเหมือนคนส่วนใหญ่
เล่าสู่กันฟัง สำหรับนาย/นาง/นางสาว ปัญหาและอุปสรรค
ASP.NET Web form
Master Page + Routing + BootStrap 3.x.x + AdminLTE 2.1.1
ของเดิมมันก็ดีอยู่แล้ว แต่แอบรู้สึกลึกลึกในใจว่า
ยืนแค่สองขามันไม่มั่นคง และอยากลองใช้ Routing ดูบ้าง
ปัญหาโปรแกรมมิ่งมันตามมาทุกทิศทุกทาง ใช้เวลาเปลืองไปมากโข
ปัญหา Sys is undefined
http://stackoverflow.com/questions/75322/sys-is-undefined
ปัญหา โหลด CSS/JavaScript/Jquery ไม่ได้
http://www.instanceofanobject.com/2012/06/include-javascript-and-css-on-your.html
ปัญหา หลงทางชี้ไม่ถูก
./FAKE_GL/page123
./FAKE_SO/page123
./FAKE_SO/SomeFolder/page123
http://stackoverflow.com/questions/6016298/how-to-create-a-asp-net-4-0-route-based-on-databinded-value
http://weblogs.asp.net/scottgu/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series
http://forumarray.com/web-forms-getrouteurl-not-working-on-master-page-543715
http://forums.asp.net/t/1597506.aspx
MasterPage Markup
<!-- Sidebar Menu -->
<ul class="sidebar-menu">
<li class="header">HEADER</li>
<!-- Optionally, you can add icons to the links -->
<li id="sidebar_menu_0">
<!--class="active" -->
<a id="sidebar_menu_0a" href='<%:Page.GetRouteUrl("MainMenu_Left", New With {.page = "test0"})%>'><i class='fa fa-link'></i><span>Sales & Marketing</span></a></li>
<li id="sidebar_menu_1">
<a id="sidebar_menu_1a" href='<%:Page.GetRouteUrl("MainMenu_Left", New With {.page = "test1"})%>'><i class='fa fa-link'></i><span>Inventory Control</span></a>
</li>
<li id="sidebar_menu_2">
<a id="sidebar_menu_2a" href='<%:Page.GetRouteUrl("MainMenu_Left", New With {.page = "test2"})%>'><i class='fa fa-link'></i><span>Purchase Orders</span></a>
</li>
<li id="sidebar_menu_4">
<cc1:my_LinkButton ID="lnkHelloWorld" runat="server" NavigateURL="ข้อความตามใจฉัน">
<i class='fa fa-link'></i><span>Account Payable</span>
</cc1:my_LinkButton>
</li>
</ul>
<!-- /.sidebar-menu -->
Coding ไฟล์ Global.asax(VB.NET)
Sub RegisterRoutes(ByVal routes As RouteCollection)
'http://weblogs.asp.net/psheriff/using-friendly-urls-in-web-forms
'Dim settings = New FriendlyUrlSettings()
'settings.AutoRedirectMode = RedirectMode.Permanent
'routes.EnableFriendlyUrls(settings)
routes.Ignore("{*allaspx}", New With {.allaspx = ".*\.aspx(/.*)?"})
routes.Ignore("{resource}.axd/{*pathInfo}") 'Fixed Sys undefined
routes.Add("MainMenu_Left_GL", New Route("FAKE_GL/{page}", New DirectoryRouteHandler(virtualDir:="~/GL")))
routes.Add("MainMenu_Left", New Route("FAKE_MAIN/{page}", New DirectoryRouteHandler(virtualDir:="~/")))
routes.Add("MainMenu_Left_SO", New Route("FAKE_SO/{page}", New DirectoryRouteHandler(virtualDir:="~/SO/FOLDER69")))
End Sub
รูปภาพประกอบ

มาถึงจุดนี้เริ่มรู้สึกว่า ตัวเองยืนด้วย 4 ขา (เมื่อก่อนยืนแค่ 2 ขา)
|
 |
 |
 |
 |
Date :
2015-05-25 10:19:46 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โอ้ว ไม่ได้เข้ามาดูนาน มีคนมาต่อยอดเพียบเลย ฮิฮิ ดีครับๆ ตอนนั้นที่ทำผมก็แค่ น.ศ. คนนึงครับ ความรู้ไม่มากมายอะไร
|
 |
 |
 |
 |
Date :
2015-10-14 15:33:18 |
By :
toekungs |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|