Welcome to WebmasterWorld Guest from 54.226.133.245

Forum Moderators: ocean10000

Message Too Old, No Replies

I need a simple script...

please help...

     
12:52 pm on Jun 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 9, 2003
posts:96
votes: 0


Hey Guys,

I need two simple ASP scripts.

1) A date function that adds 30 days to to the current date ( i will use it als a value in a dropdownlist...)

2) A script that compares the current date to a date i get from a recordset. If the dates are the same if should redirect the user to an URL.

Thanks for your help

GJ

1:16 pm on June 2, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 1, 2001
posts:4392
votes: 0


These are very simple, but different depending on your database and language

mySQL has a DATE_ADD function which you can build right into the SQL statement.

VB has a dateadd() function which you can use on the script itself.

JavaScript doesn't have a native date add function, but I found a way to do it with a few lines of code.

1:20 pm on June 2, 2004 (gmt 0)

New User

10+ Year Member

joined:Mar 11, 2004
posts:22
votes: 0


Hi Gert_Jan

hope this helps:

1) MyDate = DateAdd("d",30,Date())

2) if Date() = FormatDateTime(YourRecordsetValue,2) then Response.Redirect "/YourRedirectionURL.asp"

cheers

tafkar

1:21 pm on June 2, 2004 (gmt 0)

New User

10+ Year Member

joined:Mar 11, 2004
posts:22
votes: 0


ooops, txbakers beats me to it :-)
1:54 pm on June 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 25, 2003
posts:107
votes: 0


Only one thing I might add to this - If your ASP dropdown is supposed to contain *all* dates between now and 30 days from now, this code should do it...

<%
response.write "<select size='1' name='mydate'>" & chr(13)
For i = 0 to 30
thisdate = Date + i
response.write "<OPTION VALUE='" & thisdate & "'>" & formatdatetime(thisdate,1) & "</OPTION>" & chr(13)
Next
response.write "</select>" & chr(13)
%>

2:37 pm on June 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 9, 2003
posts:96
votes: 0


Thnk you for the help! Gat the date thing working!

Except the comparison... whats wrong with this?

Thanks in advance

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT mem_id, mem_name, mem_email, mem_subsc, mem_start_date, mem_end_date FROM members WHERE mem_name = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

<%
if Date() = FormatDateTime(mem_end_date,2) then Response.Redirect "http://www.webmasterworld.com"
%>

GJ

2:47 pm on June 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 9, 2003
posts:96
votes: 0


Thnk you for the help! Gat the date thing working!

Except the comparison... whats wrong with this?

Thanks in advance

<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT mem_id, mem_name, mem_email, mem_subsc, mem_start_date, mem_end_date FROM members WHERE mem_name = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

<%
if Date() = FormatDateTime(mem_end_date,2) then Response.Redirect "http://www.webmasterworld.com"
%>

GJ

3:20 pm on June 2, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 9, 2003
posts:96
votes: 0


Already got it!

Thanks anyway!