Professional Web Applications Themes

ASP/VBS Dates Between Dates - Dreamweaver AppDev

I'm trying to filter records depending on 2 dates requested from the querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a list records that are between: e.g. 27/4/05 and 29/4/05 the db fields t41 and t42 are (startdate and enddate respectively) SELECT tbl_work.t3, tbl_work.t1 FROM tbl_work WHERE (tbl_work.t41 >= #MMColParam1# AND tbl_work.t42 <= #MMColParam2#) AND tbl_work.app = 'a' I think the problem I'm having is the date in dd/mm/yy format Regards, Sanjay...

  1. #1

    Default ASP/VBS Dates Between Dates

    I'm trying to filter records depending on 2 dates requested from the
    querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a list
    records that are between:

    e.g. 27/4/05 and 29/4/05

    the db fields t41 and t42 are (startdate and enddate respectively)

    SELECT tbl_work.t3, tbl_work.t1 FROM tbl_work WHERE (tbl_work.t41 >=
    #MMColParam1# AND tbl_work.t42 <= #MMColParam2#) AND tbl_work.app = 'a'

    I think the problem I'm having is the date in dd/mm/yy format

    Regards,

    Sanjay



    Sanjay Guest

  2. #2

    Default Re: ASP/VBS Dates Between Dates

    I always convert the dates being passed into ISO format, this gets this type of
    Search working in Access

    Try this for changing the form value sent to your page

    <% Dim ISOStartDate
    varSDate = DatePart("d", Request("StartDate"))
    If varSDate < 10 Then
    varSDate = "0" & varSDate
    End If
    varSMonth = DatePart("m", Request("StartDate"))
    If varSMonth < 10 Then
    varSMonth = "0" & varSMonth
    End If
    varSYear = DatePart("yyyy", Request("StartDate"))
    ISOStartDate = varSYear & varSMonth & varSDate
    %>

    Of course you will need to repeat for the end Date form value, and then use
    ISOStartDate instead of your Request for the Form value in your Recordset.

    This code should be placed on the page which runs the Recordset and shows the
    results and before your recordset, usually best it is the first thing after the
    <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> line, that way you ensure it runs
    before the recordset.



    Originally posted by: Newsgroup User
    I'm trying to filter records depending on 2 dates requested from the
    querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a list
    records that are between:

    e.g. 27/4/05 and 29/4/05

    the db fields t41 and t42 are (startdate and enddate respectively)

    SELECT tbl_work.t3, tbl_work.t1 FROM tbl_work WHERE (tbl_work.t41 >=
    #MMColParam1# AND tbl_work.t42 <= #MMColParam2#) AND tbl_work.app = 'a'

    I think the problem I'm having is the date in dd/mm/yy format

    Regards,

    Sanjay







    CarlGrint Guest

  3. #3

    Default Re: ASP/VBS Dates Between Dates

    Thanks Carl!



    "CarlGrint" <webforumsusermacromedia.com> wrote in message
    news:d4qfar$1nr$1forums.macromedia.com...
    > I always convert the dates being passed into ISO format, this gets this
    type of
    > Search working in Access
    >
    > Try this for changing the form value sent to your page
    >
    > <% Dim ISOStartDate
    > varSDate = DatePart("d", Request("StartDate"))
    > If varSDate < 10 Then
    > varSDate = "0" & varSDate
    > End If
    > varSMonth = DatePart("m", Request("StartDate"))
    > If varSMonth < 10 Then
    > varSMonth = "0" & varSMonth
    > End If
    > varSYear = DatePart("yyyy", Request("StartDate"))
    > ISOStartDate = varSYear & varSMonth & varSDate
    > %>
    >
    > Of course you will need to repeat for the end Date form value, and then
    use
    > ISOStartDate instead of your Request for the Form value in your Recordset.
    >
    > This code should be placed on the page which runs the Recordset and shows
    the
    > results and before your recordset, usually best it is the first thing
    after the
    > <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> line, that way you ensure it runs
    > before the recordset.
    >
    >
    >
    > Originally posted by: Newsgroup User
    > I'm trying to filter records depending on 2 dates requested from the
    > querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a
    list
    > records that are between:
    >
    > e.g. 27/4/05 and 29/4/05
    >
    > the db fields t41 and t42 are (startdate and enddate respectively)
    >
    > SELECT tbl_work.t3, tbl_work.t1 FROM tbl_work WHERE (tbl_work.t41 >=
    > #MMColParam1# AND tbl_work.t42 <= #MMColParam2#) AND tbl_work.app = 'a'
    >
    > I think the problem I'm having is the date in dd/mm/yy format
    >
    > Regards,
    >
    > Sanjay
    >
    >
    >
    >
    >
    >
    >

    Sanjay Guest

  4. #4

    Default Re: ASP/VBS Dates Between Dates

    Is the code you see using

    ISOStartDate = varSYear & "-" & varSMonth & "-" & varSDate

    I just notice on the quote in your reply it is missing the "-"'s which is
    needed.

    Originally posted by: Newsgroup User
    Thanks Carl!



    "CarlGrint" <webforumsusermacromedia.com> wrote in message
    news:D4qfar$1nr$1forums.macromedia.com...
    > I always convert the dates being passed into ISO format, this gets this
    type of
    > Search working in Access
    >
    > Try this for changing the form value sent to your page
    >
    > <% Dim ISOStartDate
    > varSDate = DatePart("d", Request("StartDate"))
    > If varSDate < 10 Then
    > varSDate = "0" & varSDate
    > End If
    > varSMonth = DatePart("m", Request("StartDate"))
    > If varSMonth < 10 Then
    > varSMonth = "0" & varSMonth
    > End If
    > varSYear = DatePart("yyyy", Request("StartDate"))
    > ISOStartDate = varSYear & varSMonth & varSDate
    > %>
    >
    > Of course you will need to repeat for the end Date form value, and then
    use
    > ISOStartDate instead of your Request for the Form value in your Recordset.
    >
    > This code should be placed on the page which runs the Recordset and shows
    the
    > results and before your recordset, usually best it is the first thing
    after the
    > <%LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> line, that way you ensure it runs
    > before the recordset.
    >
    >
    >
    > Originally posted by: Newsgroup User
    > I'm trying to filter records depending on 2 dates requested from the
    > querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a
    list
    > records that are between:
    >
    > e.g. 27/4/05 and 29/4/05
    >
    > the db fields t41 and t42 are (startdate and enddate respectively)
    >
    > SELECT tbl_work.t3, tbl_work.t1 FROM tbl_work WHERE (tbl_work.t41 >=
    > #MMColParam1# AND tbl_work.t42 <= #MMColParam2#) AND tbl_work.app = 'a'
    >
    > I think the problem I'm having is the date in dd/mm/yy format
    >
    > Regards,
    >
    > Sanjay
    >
    >
    >
    >
    >
    >
    >





    CarlGrint Guest

Similar Threads

  1. Between Dates
    By javman in forum Coldfusion - Advanced Techniques
    Replies: 5
    Last Post: June 7th, 02:50 PM
  2. Dates & SQL
    By smokin_joe in forum Coldfusion Database Access
    Replies: 1
    Last Post: July 29th, 04:56 PM
  3. Dates again
    By Clive Moss in forum ASP Database
    Replies: 4
    Last Post: January 14th, 03:35 AM
  4. Dates
    By Support in forum PERL Beginners
    Replies: 0
    Last Post: August 19th, 08:35 AM
  5. Help with Dates please
    By Ian Piper in forum Microsoft SQL / MS SQL Server
    Replies: 4
    Last Post: July 7th, 07:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139