473,394 Members | 1,752 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,394 software developers and data experts.

date conversion

I need to write an access query that will pull records from a table if
the start or end dates input by the user are within the start and end
dates in the db. I can't use BETWEEN because either of the dates in
the db may be outside those input. Basically it's something like:

select where input.startdate <= tbl.startdate or input.endate >=
tbl.enddate

so that if the query date are start 04/01/2000 and end 09/31/2000 it
will return records with start 01/01/2000 and 06/31/2001 because the
input dates are between the record dates.

Is this possible??

There is a DATE function in access that will convert a date to a
serial number which would let me do the math but I think it needs the
year, month and day to be entered as separate parameters:
DATE(year,month,day). Is there anything that will let me just convert
a date to an number in a query?

Thanks for the help.
b
Nov 12 '05 #1
2 6505
So what's wrong with:

SELECT Staff.StaffID, Staff.StaffName, Staff.MgrID, Staff.Level
FROM Staff
WHERE (((Staff.MgrID) Not Between 3 And 4));
if you use NOT BETWEEN x AND y, you'll get all the values that are not
in that range...

say I have {1,2,3,4,5} as my entire range of X, and I ask for

SELECT X
FROM Table
WHERE Table.X NOT BETWEEN 2 AND 4;

I get {1,5} as the result set. Is that what you were after?
Nov 12 '05 #2

You can seperate a date by using

Year(myDate)
Month(myDate)
Day(myDate)

and put it back together using

DateSerial(myYear, myMonth, myDay)

Don't forget the # symbols around your dates in the SQL statement, or
convert the string returned to a date :)

eg. SELECT * FROM myTable WHERE myTable![StartDate] >= CDate([Enter Start
Date]) OR myTable![EndDate] <= CDate([Enter End Date])

--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"B Briant" <br*****@rogers.com> wrote in message
news:8e**************************@posting.google.c om...
I need to write an access query that will pull records from a table if
the start or end dates input by the user are within the start and end
dates in the db. I can't use BETWEEN because either of the dates in
the db may be outside those input. Basically it's something like:

select where input.startdate <= tbl.startdate or input.endate >=
tbl.enddate

so that if the query date are start 04/01/2000 and end 09/31/2000 it
will return records with start 01/01/2000 and 06/31/2001 because the
input dates are between the record dates.

Is this possible??

There is a DATE function in access that will convert a date to a
serial number which would let me do the math but I think it needs the
year, month and day to be entered as separate parameters:
DATE(year,month,day). Is there anything that will let me just convert
a date to an number in a query?

Thanks for the help.
b

Nov 12 '05 #3

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

Similar topics

8
by: nimish | last post by:
I have Month, Day and Year fields on my form. When I submit this form I want to create a valid date from all three fields before inserting into MYSQL table. I tried following:...
5
by: SalimShahzad | last post by:
Dear Respected Gurus, I need a coding assistant converting from gregorian to hijri and vice versa. I have problem with this codes. the problem Gregorian to Hijri gives 100% results. when i enter...
4
by: dhnriverside | last post by:
Hi peeps I have a datepicker control that's providing dates in the format dd/mm/yyyy (UK). I want to convert this to "yyyy-mm-dd" to store as a text field in my database (had lots of problems...
1
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings set...
1
by: vadala | last post by:
The requirement is to send start data and end date from java to UI (.net) for a functionality. We are setting the time in java (1.5) before handing it over to WebService (sending to UI ) in...
7
by: bruce.dodds | last post by:
Access seems to be handling a date string conversion inconsistently in an append query. The query converts a YYYYMM string into a date, using the following function: CDate(Right(,2) & "/1/" &...
2
by: p.smachylo | last post by:
Hello, I am relatively new to Microsoft Access and databases in general, and have a problem - one which I think may necessitate some VBA code (or maybe just modification of the criteria section of...
2
by: RN1 | last post by:
A TextBox displays the current date (in dd/mm/yyyy format) & time when a user comes to a page (e.g. 15/10/2008 1:36:39 PM). To convert the date into international format so that the remote server...
2
by: anderst | last post by:
Hi! I need help with date conversion, I need a perl-script that transform Wed Mar 28 00:00:00 GMT+02:00 2007 to 2007-03-28 I have tried to use perl modules Date::Manip and Date::Calc, but no...
4
maheshwag
by: maheshwag | last post by:
my code is: string sql="insert into dummy(date)values(@date) sqlcommand cmd=new sqlcommand(sql,con) cmd.parameters.Add("@date", SqlDbtype.datetime).values=maskedtextbox1.text;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.