Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 date specs in SQL
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  13:58:50  Show Profile  Visit Alfred's Homepage
If this selects records of the last 30 days:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-30,Now()) & "# and victor=''"
set LateNews = my_Conn.Execute(strSql)
should this not select records of the last 3 days?:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-3,Now()) & "# and victor=''"
set LateNews = my_Conn.Execute(strSql)


Alfred
The Battle Group
CREDO

laser
Advanced Member

Australia
3859 Posts

Posted - 16 October 2003 :  14:22:56  Show Profile
Yes, with the second statement you will get all games with a start_date somewhere in the last 3 days, and a blank victor.
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  14:29:35  Show Profile  Visit Alfred's Homepage
That is what I thought it should do.
However, it only works if I take out the "blank victor"!

Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 16 October 2003 :  14:34:56  Show Profile
Right, so there is nothing that matches the criteria of a blank victor then
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  14:39:10  Show Profile  Visit Alfred's Homepage
That would make sense, but unfortunately is not so.

I wanted to pull all unfinished games, which is why a put a blank for victor. When nothing was returned, I specifically recorded some unfinished games for the last 3 days.
I checked in the DB, and the records are all there.

At first I did this:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-3,Now()) & "# and VICTOR = ''"
set LateNews = my_Conn.Execute(strSql)
which should select all unfinished games, right?
But it never did, and I added this to the response.write:
quote:
if lateNews.eof then
response.write "NO NEW ATTACKS REPORTED!"
else
LateNEWS.movefirst
do while not LateNEWS.EOF
SO now it keeps telling me that there are no new games reported, although I just put some in.

Alfred
The Battle Group
CREDO

Edited by - Alfred on 16 October 2003 14:46:51
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 16 October 2003 :  14:46:47  Show Profile
probably the victory isn't blank but is instead Null.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  14:48:57  Show Profile  Visit Alfred's Homepage
I never understood the difference between blank and null.
When do I have to use isNull.xyz(xxx)?

Alfred
The Battle Group
CREDO
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 16 October 2003 :  14:50:52  Show Profile
the entry is null if you never inserted a value for it. the entry is empty if you set it equal to '' ... which can only be the case for text fields.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  15:11:06  Show Profile  Visit Alfred's Homepage
I see.
So in the case of a game record, when there is no victor yet, it should be NULL, right?
I insert a new record, but without a victor value.
Or does this then automatically set the victor field for ''?

Alfred
The Battle Group
CREDO
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 16 October 2003 :  15:40:52  Show Profile
if you insert a new record and you do not specify victor = '', then the value is Null. (Unless you have a default value set on the database of '').

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 16 October 2003 :  16:11:43  Show Profile  Visit Alfred's Homepage
I get it.
There is a field for victor in the report form, but I leave it open.
That means is stays null if I understand you right.

In any event, I am getting results now with this statement:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-2,Now()) & "# and isNUll(VICTOR)"
set LateNews = my_Conn.Execute(strSql)

Thank you very much!

Alfred
The Battle Group
CREDO
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 16 October 2003 :  21:04:18  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
You might want to do the following incase you clear out a games VICTOR value or the below will look for null or blank


strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-2,Now()) & "# and isNUll(VICTOR) or VICTOR=''"
set LateNews = my_Conn.Execute(strSql)

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 17 October 2003 :  17:43:17  Show Profile  Visit Alfred's Homepage
I understand, and it makes sense.

ANother strange thing happened now though.
I have set the news for thew last 7 days:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-7,Now()) & "# and isNUll(VICTOR) or VICTOR='' ORDER BY Start_Date DESC"
set LateNews = my_Conn.Execute(strSql)
and it does not show the latest game start of today!
I tested the statement on my localhost, where it does show today's record.
How can that be?

Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 17 October 2003 :  19:11:50  Show Profile
Are you running the same code AND DATA on your server ?
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 17 October 2003 :  21:03:18  Show Profile  Visit Alfred's Homepage
Same code, but there are different games registered.
I just noticed that the same day's games do not show on the server, but do on localhost.

So now, out of curiosity I transferred the DB from the server to local and guess what - it shows today's entries!

Alfred
The Battle Group
CREDO

Edited by - Alfred on 17 October 2003 21:25:59
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 17 October 2003 :  22:00:03  Show Profile
Well if the code is the same (& working properly) the only thing that can be different is your data.

You MIGHT want to look at installing Table Editor on your site then you can see the data in your db a lot easier.
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07