Date Problems

Results 1 to 2 of 2

Thread: Date Problems

  1. #1
    JustinS Guest

    Default Date Problems

    Hiyas all,<BR><BR>Posting name changed due to another "justin" making an appearance on the board :o)<BR><BR>I am still having problems with this between dates query. The query itself is as follows:<BR><BR>SQLString2 = "SELECT * from Register WHERE"<BR>SQLString2 = SQLString2 & "(Year = "& theyearfrom &" <BR>SQLString2 = SQLString2 & "AND Month = "& themonthfrom &" <BR>SQLString2 = SQLString2 & "AND Day &#062;= "& thedayfrom &" <BR>SQLString2 = SQLString2 & "AND Day &#060;= 31)"<BR>SQLString2 = SQLString2 & "OR (Year = "& theyearfrom &"<BR>SQLString2 = SQLString2 & "AND Month &#062;= "& themonthfrom &" +1)"<BR>SQLString2 = SQLString2 & "OR (Year = "& theyearto &" <BR>SQLString2 = SQLString2 & "AND Month &#060;= "& themonthto &" -1)"<BR>SQLString2 = SQLString2 & "OR (Year = "& theyearto &" <BR>SQLString2 = SQLString2 & "AND Month = "& themonthto &" <BR>SQLString2 = SQLString2 & "AND Day &#060;= "& thedayto &")"<BR><BR>(If there are any syntax errors here pls ignore them as I had to reformat it to make it a bit easier to read on the board) =)<BR><BR>Now this kinda works (thanks Matt). The actual date I was trying to bring up the information for in the database was;<BR><BR>Day: 14 <BR>Month: 09 <BR>Year: 1999<BR><BR>The FROM date was: 01/01/1999<BR>The TO date was: 13/09/1999<BR><BR>When this query is run the data IS pulled out of the database. A problem occurs (no matching records are found) when I change the Day of the TO date to anything BELOW what the day actually is. Ie in this example if I set the TO day to 12 no data is found.<BR><BR>I also tried changing the data in the database manually so that the date that was being looked up was 05/09/1999 - sure enough if I entered 5 or below into the TO "day" textbox and submitted - no data was found. Anything above and it was.<BR><BR>I&#039ve changed/tweaked/broken the SQL query lots of times but just can&#039t seem to find what is wrong with it =(<BR><BR>Any ideas anyone?<BR><BR>As always, thanks in advance for any help =)<BR><BR>Justin

  2. #2
    ActiveALLI Guest

    Default RE: Date Problems

    try to wrap up the statement as <BR>Somenthing AND SOMETHING AND (SOMETHING OR ST OR ST) AND (ST OR ST)<BR><BR>that is to put OR statments in () i had a simular problem that did it for me ..

Posting Permissions

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