 |
|
ช่วยดูโค๊ด เกี่ยวกับวันที่ให้หน่อยครับไม่รู้ว่า ดึง Date จาก SQL ไม่ได้นะครับ |
|
 |
|
|
 |
 |
|
ช่วยดูโค๊ดให้หน่อยะครับ ดึงวันเดือนปีมาแสดงว่า โค๊ดเดิมคือ ดึงจาก 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
|
|
 |
 |
 |
 |
Date :
2011-02-10 11:52:33 |
By :
supoorik |
View :
1536 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|