473,505 Members | 15,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date And Now !

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.
Jul 19 '05 #1
6 1354
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.
Jul 19 '05 #2
This is what i have come up with so far:

select invoice_member from invoice where
DateSerial(Year("invoice_date"),Month("invoice_dat e"),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
Jul 19 '05 #3
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/
"Adam Knight" <ad**********@optusnet.com.au> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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.

Jul 19 '05 #4
Adam Knight wrote:
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()'
No!
Using jetsql which would be the best way to accomplish this.


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"
Jul 19 '05 #5
Bob Barrows [MVP] wrote:
Adam Knight wrote:
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()'


No!
Using jetsql which would be the best way to accomplish this.


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


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"
Jul 19 '05 #6
PW

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
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5200
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
4
5342
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
2
4137
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
9
2621
by: Thomas R. Hummel | last post by:
Hello, I am importing data that lists rates for particular coverages for a particular period of time. Unfortunately, the data source isn't very clean. I've come up with some rules that I think...
30
3638
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
3
2560
by: captain | last post by:
Below is the sql for data with same date need to extract + or - 5 days data of same date also. How to also get data of + and - days related to same date. SELECT IM.Area, IM.Location,...
1
2798
by: Liz Malcolm | last post by:
Hello and TIA. I have a DE form with an option group that if daily is selected todays date is used for start and end date, if weekly is selected Monday - Friday is used. I am trying to add a...
7
31791
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
12
29422
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
3
2340
by: JJ | last post by:
Here's the code. $link="http://xbox360cheat.org"; $close_date=$_POST; #last content change check if ($close_date == 0) $close_date = date("Y-m-d H:m:s", mktime(12, 0, 0, date("m"), date...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.