DateAdd does not work

Discussion in 'ASP General' started by lofty, Jul 20, 2003.

  1. lofty

    lofty Guest

    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
    lofty, Jul 20, 2003
    #1
    1. Advertising

  2. lofty

    Chris Barber Guest

    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/d...y/en-us/script56/html/vsfctFormatDateTime.asp

    Chris.

    "lofty" <> wrote in message
    news:029801c34e58$5e9d94e0$...
    > 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
    >
    Chris Barber, Jul 20, 2003
    #2
    1. Advertising

  3. lofty

    lofty Guest

    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" <> wrote in message
    >news:029801c34e58$5e9d94e0$...
    >> 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
    >>

    >
    >
    >.
    >
    lofty, Jul 20, 2003
    #3
  4. lofty

    Mosley Guest

    "lofty" <> wrote in message
    news:029801c34e58$5e9d94e0$...
    > 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
    >
    Mosley, Jul 20, 2003
    #4
  5. lofty

    Bob Barrows Guest

    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
    Bob Barrows, Jul 20, 2003
    #5
  6. lofty

    Chris Barber Guest

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

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

    Chris.

    "lofty" <> wrote in message
    news:020a01c34e5e$e1d5bf80$...
    > 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" <> wrote in message
    > >news:029801c34e58$5e9d94e0$...
    > >> 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
    > >>

    > >
    > >
    > >.
    > >
    Chris Barber, Jul 20, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt Tapia

    DateAdd Function and error BC30451

    Matt Tapia, Aug 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,175
    Chris R. Timmons
    Aug 13, 2003
  2. Mel

    DateAdd Function

    Mel, Nov 4, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    6,016
  3. Tipple
    Replies:
    2
    Views:
    123
    Tipple
    Oct 16, 2003
  4. Gabe

    Dateadd function not adding up...

    Gabe, Oct 30, 2003, in forum: ASP General
    Replies:
    3
    Views:
    146
    Ray at
    Oct 31, 2003
  5. Brandon

    Dateadd in SQL statement not working

    Brandon, May 7, 2004, in forum: ASP General
    Replies:
    9
    Views:
    379
    Brandon
    May 11, 2004
Loading...

Share This Page