473,396 Members | 2,111 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.

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 6850
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Øyvind Isaksen | last post by:
Hi! I need to add 1 day to a specific date. The date have is stored in a variable called "DateOld". The value of the variable have this syntax: mm.dd.yyyy. The new date is the variable called...
9
by: Brandon | last post by:
Greetings, I am having a problem getting a SQL statement that is functional in Access 2K to work in ASP. My Access SQL statement is this: SELECT DateAdd('s',Ticket_Opened_Date,'Dec 31, 1969...
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
2
by: Abdul N K | last post by:
I need help in T-SQL. I am using DATEADD function and I want to add 6 months to a date. But it does not return me the rusults, which I want e.g. SELECT DATEADD(m,'20040630') returns 20041230...
4
by: ey.markov | last post by:
Greetings, I have an A2K application where for a report the user enters a month-end date, and the system must gather transactions for that month. No problem, I thought, I'll just use the DateAdd...
1
by: C.Davidson | last post by:
Does subject VB.net 2003 support DateAdd function? I have tried to implement the following without success. In my example I tried to simply add 30 months to 9/18/2003 and I get "New date: 12:00:00...
2
by: Rich Raffenetti | last post by:
I have the following code. If I do the dateadd function with dateinterval.minute, it works fine and the date/time value is displayed with zero seconds. If I do the dateadd function with...
4
by: Drum2001 | last post by:
I have a report that acts as a time sheet for employees. It lists there "punch-in" and "punch-out and catagorizes them by week, with different totals.. At the end of each week is a total of all...
3
by: Mel | last post by:
When I use the DateAdd function using "DateInterval.Weekday" it does not return the correct date, well at least how I thought the weekday option should work. It is counting weekends and I only...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.