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

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  00:07:10  Show Profile  Visit Alfred's Homepage
I just left the second part of the statement out, so it would include today
quote:
strSql = "SELECT COUNT(MEMBER_ID) AS NAME_COUNT FROM FORUM_MEMBERS WHERE M_DATE > '" & strPreviousDay & "'"


So laser, if I say:
quote:
strCurrentMonth = DateToStr(DateAdd("m",-1,Now()))
does that mean the current calender month, even if it was just a few days long, or the length of one whole month back?

Alfred
The Battle Group
CREDO

Edited by - Alfred on 20 October 2003 00:09:02
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 20 October 2003 :  00:21:17  Show Profile
It means the whole month back :

http://www.asp-help.com/getstarted/ms/vbscript/62.asp
http://www.w3schools.com/vbscript/func_dateadd.asp
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 October 2003 :  00:30:33  Show Profile
if you are looking only for the current month (so if it was the 5th for example, only the 1st through the 5th) then that's easy enough ... take today's date and subtract the number of days that have occurred so far in the month (which is the day part of today's date) ...

> DateAdd("d",-1*Day(Now()),Now())

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

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  00:40:07  Show Profile  Visit Alfred's Homepage
Oh, how clever!
It would have to look this way then:
quote:
strCurrentMonth = DateToStr(DateAdd("d",-1*Day(Now()),Now()))

What does the -1 mean in this calculation?

Alfred
The Battle Group
CREDO
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 20 October 2003 :  02:27:04  Show Profile
I hope this is legible :


strCurrentMonth = DateToStr(DateAdd("d",-1*Day(Now()),Now()))
                                           ^^^^^^^^^^ - get the Day number from Now()
                                        ^^^ - multiply it by -1, which just makes it the same number, but negative
                            ^^^^^^^^^^^^             ^^^^^^^^ - Do a DateAdd and 'add' X days, we are subtracting because the number is negative

Go to Top of Page

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  12:35:52  Show Profile  Visit Alfred's Homepage
This sheds a little light on it, laser.
I could not hope to figure this out myself!
Thanks, Nikkol - you are so crafty!

Alfred
The Battle Group
CREDO
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 October 2003 :  12:40:22  Show Profile
You could also do it by the following:

tempDate = CDate(Month(Now()) & "/1/" & Year(Now())) <-- assuming mm/dd/yyyy format
strCurrentMonth = DateToStr(tempDate)

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

Alfred
Senior Member

USA
1527 Posts

Posted - 20 October 2003 :  13:04:51  Show Profile  Visit Alfred's Homepage
I suspect you just relish to bogle my mind, right?
As soon as I have something that works and I can understand I should probably not mess with it...
But I know that all info can be useful for alternatives.

This topic has given me lots of fuel for new designs - thanks again!

Alfred
The Battle Group
CREDO
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous 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.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07