469,360 Members | 1,782 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

DateAdd does not work

Dear Lord,

I'm trying to code a drop down for a date entry that gives
the user the option of the current date plus the dates of
the last 7 days.

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:

Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen

Jul 19 '05 #1
5 6673
For i = 0 to -7 Step -1
If i = 0 Then
pstrSelected = " selected"
Else
pstrSelected = vbNullString
End If
Response.write "<option" & pstrSelected & " value=""" & CDate(Date() +
i) & """>" & FormatDateTime(Date() + i, 1) & "<option>"
Next

NB: vbLongDate = 1

See:
http://msdn.microsoft.com/library/de...atDateTime.asp

Chris.

"lofty" <lo*****@austarnet.com.au> wrote in message
news:02****************************@phx.gbl...
Dear Lord,

I'm trying to code a drop down for a date entry that gives
the user the option of the current date plus the dates of
the last 7 days.

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:

Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen

Jul 19 '05 #2
Thankyou,

but could u tell me why i'm getting the error

Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'DateAdd'

when i,m using dateAdd

-----Original Message-----
For i = 0 to -7 Step -1
If i = 0 Then
pstrSelected = " selected"
Else
pstrSelected = vbNullString
End If
Response.write "<option" & pstrSelected & " value=""" & CDate(Date() +i) & """>" & FormatDateTime(Date() + i, 1) & "<option>"
Next

NB: vbLongDate = 1

See:
http://msdn.microsoft.com/library/default.asp? url=/library/en-us/script56/html/vsfctFormatDateTime.asp
Chris.

"lofty" <lo*****@austarnet.com.au> wrote in message
news:02****************************@phx.gbl...
Dear Lord,

I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days.

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen

.

Jul 19 '05 #3

"lofty" <lo*****@austarnet.com.au> wrote in message
news:02****************************@phx.gbl...
Dear Lord,

I'm trying to code a drop down for a date entry that gives
the user the option of the current date plus the dates of
the last 7 days.
aharrrrrrr
NO
DateAdd(d,i,Date())

Yes
DateAdd("d",i,Date())

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:

Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen

Jul 19 '05 #4
lofty wrote:
Dear Lord,

I'm trying to code a drop down for a date entry that gives
the user the option of the current date plus the dates of
the last 7 days.

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:

Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen


I'm not a lord; however:
in vbscript, the first argument needs to be quoted since it must be a
string:
DateAdd("d",i,Date())

If you do not have the vbscript reference, it can be downloaded from here:
http://tinyurl.com/7rk6

HTH,
Bob Barrows

Jul 19 '05 #5
http://msdn.microsoft.com/library/de...fctDateAdd.asp

First parameter must be a string value (eg. "d"), not a variable reference
(eg. d).

Chris.

"lofty" <lo*****@austarnet.com.au> wrote in message
news:02****************************@phx.gbl...
Thankyou,

but could u tell me why i'm getting the error

Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'DateAdd'

when i,m using dateAdd

-----Original Message-----
For i = 0 to -7 Step -1
If i = 0 Then
pstrSelected = " selected"
Else
pstrSelected = vbNullString
End If
Response.write "<option" & pstrSelected & " value="""

& CDate(Date() +
i) & """>" & FormatDateTime(Date() + i, 1) & "<option>"
Next

NB: vbLongDate = 1

See:
http://msdn.microsoft.com/library/default.asp?

url=/library/en-us/script56/html/vsfctFormatDateTime.asp

Chris.

"lofty" <lo*****@austarnet.com.au> wrote in message
news:02****************************@phx.gbl...
Dear Lord,

I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days.

<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Today)

your guidence is sought, oh great one.
amen

.

Jul 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Řyvind Isaksen | last post: by
2 posts views Thread by Abdul N K | last post: by
4 posts views Thread by ey.markov | last post: by
1 post views Thread by C.Davidson | last post: by
2 posts views Thread by Rich Raffenetti | last post: by
4 posts views Thread by Drum2001 | last post: by
3 posts views Thread by Mel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.