473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Query with dates

daniel aristidou
491 256MB
Hi im a bit stuck on querying with dates. ive got a databse that querries using sql in visual basic 6.

I need to select only the dates which have passed or are today.
But the query returns all the records regardless of if the date has not passed

eg
Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') >= " & "'" & todaydate & "') And (Format(due_service,'dd/mm/yyyy') = " & "'" & todaydate & "')"
  3. frmcars.cars_data.refresh
I also tried like this
Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') > " & "'" & todaydate & "') And (Format(due_service,'dd/mm/yyyy') = " & "'" & todaydate & "')"
  3. frmcars.cars_data.refresh
And like this

Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') >= " & "'" & todaydate & "'"
  3. frmcars.cars_data.refresh
They all had a result either consisting only of one that was equl to the current date or all of the records.



in advance Thanks ........Extremely Thankfull for any tips
Nov 14 '07 #1
7 1430
lotus18
866 512MB
Hi im a bit stuck on querying with dates. ive got a databse that querries using sql in visual basic 6.

I need to select only the dates which have passed or are today.
But the query returns all the records regardless of if the date has not passed

eg
Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') >= " & "'" & todaydate & "') And (Format(due_service,'dd/mm/yyyy') = " & "'" & todaydate & "')"
  3. frmcars.cars_data.refresh
I also tried like this
Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') > " & "'" & todaydate & "') And (Format(due_service,'dd/mm/yyyy') = " & "'" & todaydate & "')"
  3. frmcars.cars_data.refresh
And like this

Expand|Select|Wrap|Line Numbers
  1. todaydate = format(date, "dd/mm/yyyy")
  2. frmCars.Cars_Data.RecordSource = "select *  from car_Rentals WHERE  (Format(due_service,'dd/mm/yyyy') >= " & "'" & todaydate & "'"
  3. frmcars.cars_data.refresh
They all had a result either consisting only of one that was equl to the current date or all of the records.



in advance Thanks ........Extremely Thankfull for any tips
Try to use Between...And Operator
Nov 15 '07 #2
creative1
274 100+
use # instead of & around date fields
Nov 15 '07 #3
debasisdas
8,127 Expert 4TB
I need to select only the dates which have passed or are today.
as per your statment , what about using OR operator instead of AND in the sql statment.
Nov 15 '07 #4
daniel aristidou
491 256MB
as per your statment , what about using OR operator instead of AND in the sql statment.
Thanks for your replies ill try them out thanks il psot again if ang problems
Ps i did you or as well........ i reckd my brains out lookin for solution
Nov 15 '07 #5
daniel aristidou
491 256MB
Hi guys......
I tried to change the & to # but this did not work it kept on comming up with error messages. Can someone please post the code that is correct cause im also confused as to which bit i have to apply the #.

Thanks.....
Also regarding the post mentioning between. i tried it but am not familiar with how it works.
Nov 15 '07 #6
daniel aristidou
491 256MB
Hi guys......
I tried to change the & to # but this did not work it kept on comming up with error messages. Can someone please post the code that is correct cause im also confused as to which bit i have to apply the #.

Thanks.....
Also regarding the post mentioning between. i tried it but am not familiar with how it works.
Ps please note this is for my a level so only teech me how to put the # in ect
Thanks
Nov 15 '07 #7
lotus18
866 512MB
Hi Daniel

Does your due_service and todaydate are of both date datatypes? Try to omit the format function then in the general tab, format property of due_service select shortdate. : )
Nov 15 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: paii | last post by:
I have a table that stores job milestone dates. The 2 milestones I am interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18. All jobs have TypeID 1 only some jobs have TypeID 18....
8
by: DH | last post by:
Say I have a table with two columns that matter to this example, and . And here is an example of what the rows currently look like: , 1,6/27/2001 1,6/27/2001 1,5/31/2001 2,6/27/2001...
8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
1
by: Mike Cooper | last post by:
Hi everyone, This is a tough one. I have a database full of solicitations, identifying a customer and recording initial call, first followup, second followup, etc. My boss want to be able to...
6
by: Bill R via AccessMonster.com | last post by:
I have a query: SELECT tblCalendar.CalendarDay AS LastSunday FROM tblCalendar WHERE (((tblCalendar.CalendarDay)>=(Now()-7) And (tblCalendar.CalendarDay)...
2
by: Julie Wardlow | last post by:
Help! I am calculating a future date using the DateAdd function in a query (the calculation also involves an IIf statement), and have managed to get this formula to produce the required result....
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
13
newnewbie
by: newnewbie | last post by:
I have an Access database that I upload a data extract intoto daily. I want to create a query that will give me a list of dates that no data can be found for. E.g. there are no records created on the...
5
by: veaux | last post by:
I'm thinking this is easy but can't get it. I have a table with following: Table1 Date 1/1/2007 Table2 Type 0107 (This is MMYY of above) So I'm having trouble using a query to turn the...
2
by: markcarroll | last post by:
I have a rather complicating query (the SQL is about a page long) so I hope I can solve this without needing to get into specifics. Basically, the database I am working on has information about...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.