Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SQL Server Select using a Date var (SQL Server 2000, ASP classic)

    <font color=red>Problem solved. Wrapping the var in single quotes finds the data specified.</font color=red>

    I suspect my SQL statement my be failing to find an existing record. here's the SQL"
    <font face="Georgia">Query = "SELECT Count(Entity_TIN) FROM Entity_Information WHERE Entity_TIN =" & Entity_TIN & " AND Entity_FY= " & Entity_FY
    </font face=georgia>
    The variables are built from a form POST and the date is constructed using this code:
    <font face="Georgia">Entity_FY = Request.Form("EntityFY_month") & "/" & Request.Form("EntityFY_day") & "/" & Request.Form("EntityFY_year")
    </font face=georgia>
    I know in Access you have to wrap dates in '#' to get a match but I wonder whether SQL Server needs something like that (from Books Online it doesn't seem to) -- and does SQL Server allow you to match a date? Is there something obvious I am doing wrong?

    TIA
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SQL Server Select using a Date var (SQL Server 2000, ASP classic)

    sure does

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: SQL Server Select using a Date var (SQL Server 2000, ASP classic)

    Does it work if you use the following?

    <code>Query = ... & " AND Entity_FY = '" & Entity_FY & "'"</code>

    Added: OK, I see you found it yourself.

Posting Permissions

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