Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP > ASP Forum > ช่วยดูโค๊ด เกี่ยวกับวันที่ให้หน่อยครับไม่รู้ว่า ดึง Date จาก SQL ไม่ได้นะครับ



 

ช่วยดูโค๊ด เกี่ยวกับวันที่ให้หน่อยครับไม่รู้ว่า ดึง Date จาก SQL ไม่ได้นะครับ

 



Topic : 055817



โพสกระทู้ ( 10 )
บทความ ( 0 )



สถานะออฟไลน์




ช่วยดูโค๊ดให้หน่อยะครับ ดึงวันเดือนปีมาแสดงว่า โค๊ดเดิมคือ ดึงจาก Access นะครับตอนนี้up เป็น SQL 2003 นะครับ



<%
pageLen = 99 'กำหนดจำนวนแต่ละหน้าที่ต้องการแสดงกี่ Reccord
pageNo = request.QueryString("pageNo")
if pageNo="" then pageNo = 1
IF Trim(Request.QueryString("q")) <> "" Then
strCondition = " and Workname like '%"&Trim(Request.QueryString("q")) &"%' "
End If

IF (Trim(Request.QueryString("StatusID")) <> "") Then
strCondition = strCondition & " and StatusID IN (" & Request.QueryString("StatusID") & ")"
End If

Select Case Request.QueryString("period")
Case 0
DateF= Year(Date)& "-" &Month(Date) & "-" & Day(Date)'& " 00:00:00', 102"
DateT= Year(Date)& "-" &Month(Date) & "-" & Day(Date)' & " 00:00:00', 102

'strCondition =" and StartDate between #"&DateF&"# and #"& DateT&"#"

Case 1
'IF (Trim(Request.QueryString("Date1")) <> "") And (Trim(Request.QueryString("Date2")) <> "") Then

DateF= Year(CDATE(Request.QueryString("Date1")) )& "-" &Month(CDATE(Request.QueryString("Date1"))) & "-" & Day(CDATE(Request.QueryString("Date1")))'& " 00:00:00', 102"
DateT= Year(CDATE(Request.QueryString("Date2"))) & "-" &Month(CDATE(Request.QueryString("Date2")) )& "-" & Day(CDATE(Request.QueryString("Date2")))' & " 00:00:00', 102

strCondition =" and StartDate between #"&DateF&"# and #"& DateT&"#"


Case 2
DateF= Request.QueryString("period_year")& "-" &Request.QueryString("period_month") & "-01" '& " 00:00:00', 102"

If Request.QueryString("period_month") = 12 Then
NextMonth = 1
NextYear = Request.QueryString("period_year")+543 +1
Else
NextMonth = Request.QueryString("period_month")+1
NextYear = Request.QueryString("period_year")+543
End If
cDateT= CDATE("01-" &NextMonth& "-" & NextYear)-1
DateT= Year(CDATE(cDateT)) & "-" &Month(CDATE(cDateT))& "-" & Day(CDATE(cDateT))' & " 00:00:00', 102
strCondition =" and StartDate between #"&DateF&"# and #"& DateT&"#"

Case 3
DateF= Request.QueryString("period_year")& "-" &Request.QueryString("period_month")*3+1 & "-01" '& " 00:00:00', 102"

If Request.QueryString("period_month") = 3 Then
NextMonth = 1
NextYear = Request.QueryString("period_year")+543 +1
Else
NextMonth = Request.QueryString("period_month")*3+4
NextYear = Request.QueryString("period_year")+543
End If
cDateT= CDATE("01-" &NextMonth& "-" & NextYear)-1
DateT= Year(CDATE(cDateT)) & "-" &Month(CDATE(cDateT))& "-" & Day(CDATE(cDateT))' & " 00:00:00', 102

strCondition =" and StartDate between #"&DateF&"# and #"& DateT&"#"

Case 4
DateF= Request.QueryString("period_year")& "-01-01" '& " 00:00:00', 102"
DateT= Request.QueryString("period_year") & "-12-31" ' & " 00:00:00', 102
strCondition =" and StartDate between #"&DateF&"# and #"& DateT&"#"

End Select

IF (Trim(Request.QueryString("StatusID")) <> "") Then
strCondition = strCondition & " and StatusID IN (" & Request.QueryString("StatusID") & ")"
End If

Sql ="SELECT *FROM Work where 1=1 "&strCondition&" and OfficerID IN (Select OfficerID from Officer where DivisionID = "&RsAdmin.Fields("DivisionID").Value&" and SectionID = "&RsAdmin.Fields("SectionID").Value&" ) "&strCondition1&" order by StartDate DESC"

Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
if NOT Rs.EOF Then
Nrecord=RS.recordcount
rs.pageSize = pageLen
totalPage = rs.PageCount
rs.absolutePage = pageNo
recNo=1
'*** แสดงข้อมูลทุก Record ที่อยู่ในช่วง Page ***'
Do While Not RS.EOF and recNo <= pageLen
k = k +1

%>



Tag : ASP, Ms SQL Server 2005







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-02-10 11:52:33 By : supoorik View : 1465 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

น่าจะผิดที่ Format น่ะครับ


Go to : SQL DATE , DAY , MONTH , YEAR






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-10 23:49:12 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดูโค๊ด เกี่ยวกับวันที่ให้หน่อยครับไม่รู้ว่า ดึง Date จาก SQL ไม่ได้นะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่