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
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

Alfred
Senior Member

USA
1527 Posts

Posted - 17 October 2003 :  22:50:34  Show Profile  Visit Alfred's Homepage
But laser, as I said, I just downloaded the data from my server, so it is identical.

Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 17 October 2003 :  23:57:37  Show Profile
OK, you've lost me ...
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 18 October 2003 :  00:53:28  Show Profile  Visit Alfred's Homepage
How so?
To make sure that I have identical data on my server and on localhost I downloaded the Access database file from the server to localhost.

Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 18 October 2003 :  01:03:50  Show Profile
I can't figure out what you mean in your 17 October 2003 : 21:03:18 post. It sounds like you've got something out of sync somewhere - whether it be code or data. That's why I suggested using Table Editor, so you can confirm what's on the server without the upload/download all the time.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 18 October 2003 :  08:10:33  Show Profile  Send ruirib a Yahoo! Message
Have looked at the server date and time? Looks an obvious source of problems. If Now() is returning a wrong value, that can explain the issue you're facing...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 18 October 2003 :  12:44:39  Show Profile  Visit Alfred's Homepage
That may have been the trouble with the serverr yesterday, because it reports properly in time sync now.
Look how nicely it reports: http://www.ggholiday.com/bg/forums/DEFAULT.ASP

quote:
I discovered another error though:
Posted - 16 October 2003 : 21:04:18
--------------------------------------------------------------------------------
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)
Since the "or" has priority, the above would select all games without a victor, regardless of date.
So I added the red part:
quote:
strSql = "SELECT * FROM Games WHERE Start_Date > #" & DateAdd("d",-2,Now()) & "# and isNUll(VICTOR) or Start_Date > #" & DateAdd("d",-2,Now()) & "# and VICTOR=''"
set LateNews = my_Conn.Execute(strSql)


Many thanks for all suggestions!


Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 18 October 2003 :  18:13:44  Show Profile
A better way would be :

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

You are defining your own precedence using this method.
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 18 October 2003 :  19:09:07  Show Profile  Visit Alfred's Homepage
Thanks, laser, good to know!

Alfred
The Battle Group
CREDO
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 18 October 2003 :  23:15:07  Show Profile  Visit Alfred's Homepage
When I tried to collect data from the forum_members table to see see new members of the last 30 days, writing:
quote:
strSql = "SELECT COUNT(MEMBER_ID) AS NAME_COUNT FROM FORUM_MEMBERS WHERE M_SINCE > #" & DateAdd("d",-30,Now()) & "#"
it returned nothing.
Checking, I found the M_DATE to be a text field.
Is there a way to translate the data in that field so it can be used as date for my purpose?

Alfred
The Battle Group
CREDO

Edited by - Alfred on 19 October 2003 17:21:33
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 19 October 2003 :  17:52:39  Show Profile  Send ruirib a Yahoo! Message
There is a function in inc_func_common.asp, StrToDate. That's what you need to get the date in Date format.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 19 October 2003 :  18:25:08  Show Profile  Visit Alfred's Homepage
I found the code:
quote:
function StrToDate(strDateTime)
if ChkDateFormat(strDateTime) then
'Testing for server format
if strComp(Month("04/05/2002"),"4") = 0 then
StrToDate = cdate("" & Mid(strDateTime, 5,2) & "/" & Mid(strDateTime, 7,2) & "/" & Mid(strDateTime, 1,4) & " " & Mid(strDateTime, 9,2) & ":" & Mid(strDateTime, 11,2) & ":" & Mid(strDateTime, 13,2) & "")
else
StrToDate = cdate("" & Mid(strDateTime, 7,2) & "/" & Mid(strDateTime, 5,2) & "/" & Mid(strDateTime, 1,4) & " " & Mid(strDateTime, 9,2) & ":" & Mid(strDateTime, 11,2) & ":" & Mid(strDateTime, 13,2) & "")
end if
else
if strComp(Month("04/05/2002"),"4") = 0 then
tmpDate = DatePart("m",strForumTimeAdjust) & "/" & DatePart("d",strForumTimeAdjust) & "/" & DatePart("yyyy",strForumTimeAdjust) & " " & DatePart("h",strForumTimeAdjust) & ":" & DatePart("n",strForumTimeAdjust) & ":" & DatePart("s",strForumTimeAdjust)
else
tmpDate = DatePart("d",strForumTimeAdjust) & "/" & DatePart("m",strForumTimeAdjust) & "/" & DatePart("yyyy",strForumTimeAdjust) & " " & DatePart("h",strForumTimeAdjust) & ":" & DatePart("n",strForumTimeAdjust) & ":" & DatePart("s",strForumTimeAdjust)
end if
StrToDate = tmpDate
end if
end function
But what to do with it?

Alfred
The Battle Group
CREDO
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 19 October 2003 :  20:31:19  Show Profile  Send ruirib a Yahoo! Message
Get the value from the DB and call the function with it. The function will then return the value you can use in your SQL statement. Here is an example:


myDate = StrToDate(rs(M_DATE))



Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 19 October 2003 :  22:22:34  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Actually if you are trying to get the past 30 days of new members you will need to do something like the following...

1. Grab todays date and 30 days ago date and convert them using the DateToStr function
2. Run your sql query to grab numbers between the two days.

Here is a real quick example if you are using the snitz database and just want to grab the last members of a certain time frame...

strCurrentDate = DateToStr(Now)
strPreviousDay = DateToStr(DateAdd("d",-30,Now()))
strSql = "SELECT COUNT(MEMBER_ID) AS NAME_COUNT FROM FORUM_MEMBERS WHERE M_DATE > '" & strPreviousDay & "' AND M_DATE < '" & strCurrentDate & "'"



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

Alfred
Senior Member

USA
1527 Posts

Posted - 19 October 2003 :  22:42:08  Show Profile  Visit Alfred's Homepage
Aha - that was the part I still couldn't figure out!
This seems to work fine now.
Does AND M_DATE < '" & strCurrentDate & " not exclude today's date?
And how would one have to specify say "the current month" rather than the last 30 days?

Alfred
The Battle Group
CREDO

Edited by - Alfred on 19 October 2003 22:45:21
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 19 October 2003 :  23:52:00  Show Profile
That's right < means less than. If you wanted today's date you would use <= instead (although I haven't tested this)

Wouldn't current month simply be the DateAdd function using m-1 rather than d-30 ?
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | 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.42 seconds. Powered By: Snitz Forums 2000 Version 3.4.07