access date query

Please support our ASP.NET advertiser: 50% Off 6 Months Web Hosting from 1&1. The World's #1 Host!
Thread Solved

Join Date: Apr 2007
Posts: 30
Reputation: DeOiD is an unknown quantity at this point 
Solved Threads: 0
DeOiD DeOiD is offline Offline
Light Poster

access date query

 
0
  #1
May 7th, 2007
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...
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: access date query

 
0
  #2
May 7th, 2007
can you give us some sample data?
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 30
Reputation: DeOiD is an unknown quantity at this point 
Solved Threads: 0
DeOiD DeOiD is offline Offline
Light Poster

Re: access date query

 
0
  #3
May 7th, 2007
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
bd.JPG  
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 30
Reputation: DeOiD is an unknown quantity at this point 
Solved Threads: 0
DeOiD DeOiD is offline Offline
Light Poster

Re: access date query

 
0
  #4
May 8th, 2007
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") & "#)"


Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum


Views: 2736 | Replies: 3
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC