473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP + Format Dates from Database

I already have a calendar from VBScript but I need it to bold on the
dates when there is an event. I've created the Database connection
but I can't seem to figure out how to integrate the two.

I HAVE TO FIGURE OUT HOW TO ADD THE DATBASE CONNECTION
-----
<%
R.Open strMonth, obConn, 3,3,1
Do While Not R.EOF

R.MoveNext
Loop
R.Close
Set R = Nothing
%>
----
TO THE CALENDAR
-----

<TABLE width="160" height="64" BORDER=1 CELLPADDING=1 cellspacing="0"
bordercolor="#666666" bgcolor="#CCCC99">
<TR>
<TD height="50">

<%
Function GetDaysInMonth(iMonth, iYear)
Dim dTemp
dTemp = DateAdd("d", -1, DateSerial(iYear, iMonth + 1, 1))
GetDaysInMonth = Day(dTemp)
End Function
Function GetWeekdayMonthStartsOn(dAnyDayInTheMonth)
Dim dTemp
dTemp = DateAdd("d", -(Day(dAnyDayInTheMonth) - 1),
dAnyDayInTheMonth)
GetWeekdayMonthStartsOn = WeekDay(dTemp)
End Function

Function SubtractOneMonth(dDate)
SubtractOneMonth = DateAdd("m", -1, dDate)
End Function

Function AddOneMonth(dDate)
AddOneMonth = DateAdd("m", 1, dDate)
End Function

Dim dDate ' Date we're displaying calendar for
Dim iDIM ' Days In Month
Dim iDOW ' Day Of Week that month starts on
Dim iCurrent ' Variable we use to hold current day of month as we
write table
Dim iPosition ' Variable we use to hold current position in table
'Database connection
Dim objConn, strQuery, RS
Dim obConn, strMonth, R
Dim strConnection
Dim stConnection
Dim dtDateEv

dtDateEv = CDate(Request.QueryString("date"))

Set objConn = Server.CreateObject("ADODB.Connection")
Set obConn = Server.CreateObject("ADODB.Connection")

strConnection = "DSN=SERF;Database=PMA;"
strConnection = strConnection & "UID=sa;PWD=;"

stConnection = "DSN=SERF;Database=PMA;"
stConnection = stConnection & "UID=sa;PWD=;"

objConn.Open strConnection
obConn.Open stConnection

Set RS = Server.CreateObject("ADODB.Recordset")
Set R = Server.CreateObject("ADODB.Recordset")

If Request.QueryString("date") <> "" Then
strQuery = "Select * from ptbSpecialEvent Where EventDate=#" &
dtDateEv & "# Order By EventDate"
strMonth = "Select EventDate from ptbSpecialEvent"
Else
strQuery = "Select * from ptbSpecialEvent"
End IF

If IsDate(Request.QueryString("date")) Then
dDate = CDate(Request.QueryString("date"))
Else
If IsDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year")) Then
dDate = CDate(Request.QueryString("month") & "-" &
Request.QueryString("day") & "-" & Request.QueryString("year"))
Else
dDate = Date()

If Len(Request.QueryString("month")) <> 0 Or
Len(Request.QueryString("day")) <> 0 Or
Len(Request.QueryString("year")) <> 0 Or
Len(Request.QueryString("date")) <> 0 Then
Response.Write "The date you picked was not a valid date. The
calendar was set to today's date.<BR><BR>"
End If

End If
End If

iDIM = GetDaysInMonth(Month(dDate), Year(dDate))
iDOW = GetWeekdayMonthStartsOn(dDate)

%>
<STYLE>
A {
text-decoration: none;
color: black
}
</STYLE>
<TABLE width="100%" CELLPADDING=1 CELLSPACING=0>
<TR>
<TD ALIGN="center" COLSPAN=7>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=0
CELLPADDING=0>
<TR>
<TD width="5%" ALIGN="right"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%=
SubtractOneMonth(dDate) %>"><img
src="file:///C|/Inetpub/wwwroot/arrow_month_nav_left.gif" width="8"
height="8" border="0"></A></TD>
<TD width="90%" ALIGN="center"><B><%=
MonthName(Month(dDate)) & " " & Year(dDate) %></B></TD>
<TD width="5%" ALIGN="left"><A
HREF="file:///D|/wwwroot1/test/index.asp?date=<%= AddOneMonth(dDate)
%>"><img src="file:///C|/Inetpub/wwwroot/arrow_month_nav.gif"
width="8" height="8" border="0"></A></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD height="23" ALIGN="center">S</TD>
<TD ALIGN="center">M</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">W</TD>
<TD ALIGN="center">T</TD>
<TD ALIGN="center">F</TD>
<TD ALIGN="center">S</TD>
</TR>
<%

If iDOW <> 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
iPosition = 1
Do While iPosition < iDOW
Response.Write vbTab & vbTab & "<TD>&nbsp;</TD>" & vbCrLf
iPosition = iPosition + 1
Loop
End If

R.Open strMonth, obConn

iCurrent = 1
iPosition = iDOW
Do While iCurrent <= iDIM

If iPosition = 1 Then
Response.Write vbTab & "<TR>" & vbCrLf
End If

Do While Not R.EOF
Response.Write vbTab & vbTab & "<TD align=center><A
HREF=""index.asp?date=" & Month(dDate) & "-" & iCurrent & "-" &
Year(dDate) & """>" & iCurrent & "</A></TD>" & vbCrLf

Loop

If iPosition = 7 Then
Response.Write vbTab & "</TR>" & vbCrLf
iPosition = 0
End If

iCurrent = iCurrent + 1
iPosition = iPosition + 1
Loop

R.Close
Set R = Nothing

If iPosition <> 1 Then
Do While iPosition <= 7
Response.Write vbTab & vbTab & "<TD>&nbsp;</TD>" & vbCrLf
iPosition = iPosition + 1
Loop
Response.Write vbTab & "</TR>" & vbCrLf
End If
%>
</TABLE>
</TD>
</TR>
</TABLE>
----
Jul 19 '05 #1
0 3372

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stefan van Roosmalen | last post by:
Hi there, I have developed several applications in Delphi. I used Paradox for my data storage. Now, I want to convert these databases to MySql. So that why I am looking for a way to convert the...
15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
5
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
5
by: Fabian | last post by:
I am making a winforms-program in Visual Studio, that connects to an Access database. In the database all dates are presented in this format : dd-mm-yyyy. In my application I have a DatetimePicker,...
13
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way...
3
by: Chu | last post by:
In playing with asp.net 2.0, I've been impressed with the internationalization support that's built right in. It's great that I can simply add a tag to my page's directive and it magically...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
5
by: turnitup | last post by:
I have found that by far the easiest way to store dates in my LAMP application is in a text string in the database in Unixtime format. First of all, what would be the most efficient data type to...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
3
Chittaranjan
by: Chittaranjan | last post by:
Hi All, I am not sure how to change the date format in PostgreSQL. I have the dates stored in the database as yyyy-mm-dd HH:MM:SS+TimeZone to get the GMT time (Ex: 2008-02-28 14:03:23+05:30). But...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.