943,832 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 3203
  • ASP.NET RSS
May 7th, 2007
0

access date query

Expand Post »
hi

i want to obtain a value of a table with date restrictions, so i created two fields, one for the inicial date and other for the final date. when i try to do that the result is always null...i don't no why...

i use this statement:
"SELECT caminho_foto FROM destaques WHERE (data_inicial <= #" & Date.Today & "#) AND (data_final >= #" & Date.Today & "#) ORDER BY id_destaque DESC"


please help me...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
DeOiD is offline Offline
30 posts
since Apr 2007
May 7th, 2007
0

Re: access date query

can you give us some sample data?
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
May 7th, 2007
0

Re: access date query

by sample data you mean values from the bd table?
the attached imagem is a print of my table, the last two fields are for the inicial and final date (their names are in portuguese, date(eng) = data(pt)), and their are both date/time fields, theres no error but theres no results also.
strangely, if i use the web developer query builder on a accessdatasource with the value 07-05-2007, it works...
Attached Thumbnails
Click image for larger version

Name:	bd.JPG
Views:	24
Size:	15.0 KB
ID:	3379  
Reputation Points: 10
Solved Threads: 0
Light Poster
DeOiD is offline Offline
30 posts
since Apr 2007
May 8th, 2007
0

Re: access date query

well, after one giant headaque i figured out why it didn't work...

in my sql statement i used date.today (or date.today.tostring("d")) to obtain the date. the result was in this format 08-05-2007. the same format as the date fields in my DB. so i thought that the error could not be this, but it is...althought i don't understand i... to work i had to change the dd/mm order to mm/dd using Date.Today.ToString("MM-dd-yyyy").

so i had:
"SELECT caminho_foto FROM destaques WHERE (data_inicial <= #" & Date.Today.ToString("d") & "#) AND (data_final >= #" & Date.Today.ToString("d") & "#)"
and now i have:
"SELECT caminho_foto FROM destaques WHERE (data_inicial <= #" & Date.Today.ToString("MM-dd-yyyy") & "#) AND (data_final >= #" & Date.Today.ToString("MM-dd-yyyy") & "#)"


Reputation Points: 10
Solved Threads: 0
Light Poster
DeOiD is offline Offline
30 posts
since Apr 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: need u r help
Next Thread in ASP.NET Forum Timeline: Help again please>>>>





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC