473,698 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,Dat e())
& "<option>"
next
%>
Besides this, even the following code generates an error:

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

your guidence is sought, oh great one.
amen

Jul 19 '05 #1
5 6861
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*****@austar net.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,Dat e())
& "<option>"
next
%>
Besides this, even the following code generates an error:

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

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/vsfctFormatDate Time.asp
Chris.

"lofty" <lo*****@austar net.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,Dat e())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Tod ay)

your guidence is sought, oh great one.
amen

.

Jul 19 '05 #3

"lofty" <lo*****@austar net.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,Dat e())

Yes
DateAdd("d",i,D ate())

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

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

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,Dat e())
& "<option>"
next
%>
Besides this, even the following code generates an error:

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

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,D ate())

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*****@austar net.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/vsfctFormatDate Time.asp

Chris.

"lofty" <lo*****@austar net.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,Dat e())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Tod ay)

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
10065
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 "DateNew". This is my code that dont work: DateNew = DATEADD(d,1,DateOld)
9
5523
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 8:00:00PM') AS Opened_Date, AL.Last_Significant_Update_Date AS Last_Updated, AL.Due_Date AS Ticket_Due_Date, AL.Managing_Station,
1
17327
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 dateadd(year,1,dateadd(month,-1,getdate())) AND dateadd(day,-1,(dateadd(month,1,dateadd(year,1,dateadd(month,-1,getdate()))))) *************** (first part of the date calculation comes out to be '2005-05-01' and
2
37611
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 which is logical correct? But I want it to return end of month (i.e. 20041231) Any help in this context will be highly appreciated
4
10162
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 function for the beginning of the date range, like this: Between DateAdd("m",-1,!!) And !!
1
18992
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 AM", no date Example direct from VB Language Reference: Public Overloads Function DateAdd(ByVal Interval As DateInterval,_ ByVal Number As Double, ByVal DateValue As DateTime) As DateTime End Function
2
4554
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 dateinterval.second, an error is thrown saying I have an overflow. I would be happy to know if I am doing something wrong or if I could do it differently to get the seconds to display properly. Const largeInteger As Long = &H1C5EA3B5F585F1F Const...
4
1840
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 the hours for the week. The pay week is from Monday -> Sunday, but with the query below, it is totaling Sunday -> Saturday. Does anyone know how I could "shift" the work week? Any help would be great!!!!!!!!!
3
6270
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 want it to count the weekdays (Mon-Fri). How can I get it to work? (using Asp.net 2.0, vb.net) Example: dPlanFD = DateAdd(DateInterval.Weekday, 10, "11/04/2008") 'dPlanFD = #11/14/2008# 'I want it to return #11/18/2008#
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.