Groups | Blog | Home
all groups > inetserver asp general > may 2004 >

inetserver asp general : Date And Now !


dlbjr
5/29/2004 10:01:39 PM
Place this text in the field item of a query:

SDATE: DateSerial(Year([STAMP]),Month([STAMP]),Day([STAMP]))

Replace the word STAMP with the exact name of your date field name.

'from dlbjr

'Unambit from meager knowledge of inane others,engender uncharted sagacity.

Aaron Bertrand [MVP]
5/29/2004 11:55:03 PM
If you have an index on the datecolumn, then the most efficient query would
be


WHERE datecolumn >= Date() AND datecolumn < dateadd("d", 1, Date())


--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


[quoted text, click to view]

Bob Barrows [MVP]
5/30/2004 7:48:45 AM
[quoted text, click to view]

No!

[quoted text, click to view]

Select ... WHERE datefield >= Date() AND datefield < Date()


HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Bob Barrows [MVP]
5/30/2004 7:58:25 AM
[quoted text, click to view]

Oops! I forgot the DateAdd(). See Aaron's post.

Bob
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Adam Knight
5/30/2004 12:31:38 PM
I have stored a date value using the now function.
This stores dates like this: 5/3/2004 3:59:23 PM

I am wanting to run a query that compares todays date with the date in the
db field.
I imagine this means i have to isolate only the date section of the input
saved by using 'NOW()'
Using jetsql which would be the best way to accomplish this.

Thanks,
Adam.

Adam Knight
5/30/2004 1:52:20 PM
This is what i have come up with so far:

select invoice_member from invoice where
DateSerial(Year("invoice_date"),Month("invoice_date"),Day("invoice_date")) =
DateAdd("yyyy",-1,Date)

When i try to execute this i am getting an error; 'this expression is typed
incorrectly or to complex'. Can anyone see a problem with this code.

AK

PW
5/30/2004 8:11:26 PM

In this example, I am searching for records that fall between two dates ...

mySQL = "Select * from myTable where some_column = some_value "
if Request.QueryString("txtDateFrom") <> "" then
myDateFrom = CDate(Request.QueryString("txtDateFrom"))
myDD = Day(myDateFrom)
myMM = right("00" & Month(myDateFrom),2)
myYYYY = Year(myDateFrom)
myISOfr = myYYYY & "-" & myMM & "-" & myDD
mySQL = mySQL & "and CommDate >= #" & myISOfr & "# "
End if
if Request.QueryString("txtDateTo") <> "" then
myDateTo = CDate(Request.QueryString("txtDateTo"))
myDD = Day(myDateTo)
myMM = right("00" & Month(myDateTo),2)
myYYYY = Year(myDateTo)
myISOto = myYYYY & "-" & myMM & "-" & myDD
mySQL = mySQL & "and CommDate <= #" & myISOto & "# "
End if

AddThis Social Bookmark Button