473,399 Members | 3,038 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,399 software developers and data experts.

Help with Date Data Type ( i dont want to hold the year)

I have a Vehicle MOT field in my table which i have as a Date field
I dont really want to hold the year, just 'dd mmm' as MOTs are the
same date every year.
I have the field on my form as a listbox holding all the dates of the
year, except 29 Feb which i dont need anyway.
When i select a value from the list i.e. 14 May and it stores it in
the table i believe it stores the current year as well i.e 14 May 2004

The problem now is how do i write these query that finds MOT Dates?

1. Select * FROM Vehicle WHERE MOT_Due_Date LIKE "Aug"
This woud find all the dates in August, can you use LIKE when
finding Dates?

2. Select * FROM Vehicle WHERE MOT_Due_Date = "10 Oct"
This would find only 10th Oct Dates? this doesnt work either as
MOT_Due_Date has the year as well.

3. I use
WHERE ((([Vehicle_Customer].[MOT_Due_Date]) Between
DateSerial(Year(Now
()),Month(Now()),1) And
DateAdd("w",DateSerial(Year(Now()),Month(Now
()),1),42)))
to search for MOTs between the 1st of the current month and 42 days
after
but since the current year is held in the table field, this query
will only
work for the year in which the records were entered and will fail
next year
and all years after.
Should i go back to storing the MOT_Due_Date as a text field and do
date conversions?

TIA
Doug
Nov 12 '05 #1
2 2410
"Douglas" <do********@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
I have a Vehicle MOT field in my table which i have as a Date field
I dont really want to hold the year, just 'dd mmm' as MOTs are the
same date every year.
I have the field on my form as a listbox holding all the dates of the
year, except 29 Feb which i dont need anyway.
When i select a value from the list i.e. 14 May and it stores it in
the table i believe it stores the current year as well i.e 14 May 2004

The problem now is how do i write these query that finds MOT Dates?

1. Select * FROM Vehicle WHERE MOT_Due_Date LIKE "Aug"
This woud find all the dates in August, can you use LIKE when
finding Dates?

2. Select * FROM Vehicle WHERE MOT_Due_Date = "10 Oct"
This would find only 10th Oct Dates? this doesnt work either as
MOT_Due_Date has the year as well.

3. I use
WHERE ((([Vehicle_Customer].[MOT_Due_Date]) Between
DateSerial(Year(Now
()),Month(Now()),1) And
DateAdd("w",DateSerial(Year(Now()),Month(Now
()),1),42)))
to search for MOTs between the 1st of the current month and 42 days
after
but since the current year is held in the table field, this query
will only
work for the year in which the records were entered and will fail
next year
and all years after.
Should i go back to storing the MOT_Due_Date as a text field and do
date conversions?

TIA
Doug

My advice would be store them as dates and include the year. Although MOT's
generally have the same dates from year to year, they are not like birthdays
which (apart from a leap year) can be guaranteed to be on the same date each
year. There may be a number of cases where the date varies.
For example, the MOT expires on Jan 27 so you take it in on Jan 18 to get
the certificate. If you don't bring the old one, the garage must issue the
new one from the 18th so you lose a few days. Even if you do bring the new
one, my local garage seems to think if the old one expires on the 27th then
the new one expires on the 26th. I disagree, but he's the one who signs the
certificate. Another example is if the car is off the road for whatever
reason, then you don't need an MOT, so if people go abroad for a couple of
months, then there may well be a gap in the MOT history. So it could be
that the old one expires end Dec 03, there is a gap and the new one expires
Jan 05.
Anyway, if you are certain that you will ignore the year part of the date,
then you can do that and write a function like the one below. Just paste it
in a new module and you will be able to use it in your queries. It might
prove quite useful.

Public Function DaysToMOT(MOTDate) As Variant

On Error GoTo ExitHere

Dim dteThisYearMOT As Date
Dim dteNextMOT As Date

If IsNull(MOTDate) Then Exit Function

MOTDate = CDate(MOTDate)

dteThisYearMOT = DateSerial(Year(Date), Month(MOTDate), Day(MOTDate))

If dteThisYearMOT >= Date Then
dteNextMOT = dteThisYearMOT
Else
dteNextMOT = DateAdd("yyyy", 1, dteThisYearMOT)
End If

DaysToMOT = dteNextMOT - Date

ExitHere:
Exit Function

End Function
Nov 12 '05 #2
On 15 Jan 2004 01:55:36 -0800, do********@yahoo.com (Douglas) wrote:
I have a Vehicle MOT field in my table which i have as a Date field
I dont really want to hold the year, just 'dd mmm' as MOTs are the
same date every year.


You know what the date is, but you don't want to store it, because
it's the same every year, and everyone knows what it is? Does Y2K
ring a bell? <g>

--
Mike Sherrill
Information Management Systems
Nov 12 '05 #3

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

Similar topics

1
by: Yong Wang | last post by:
> Hi: > We have a database system. In the database, we have an > attribute called date0, which contains date data (format: > i. e. 2004-08-12). I wrote a script to fetch the data > in a...
2
by: Remi Caron | last post by:
Hi, I took over an Visual Object project (Visual Clipper) in that language there is a function to: Convert a string containing a 32-bit binary date to a date data type. That function is called...
1
by: Alan | last post by:
Any data type that I can use to store date ?
1
by: glenn | last post by:
Hi folks, I am doing an UPDATE to a table that has a field for a DATE data type. I am using MS Access. The UPDATE works fine but when I try to place the DATE field in the mix it blows up. ...
3
by: glenn | last post by:
Hi folks, I have 2 code snippets. One works and one does not. This first hard-coded snippet works Dim queryString As String = "UPDATE SET = '8/16/2006' WHERE (. = @id)" This second...
4
by: loisk | last post by:
Hi, I need to compare a date (on a form )entered by a user with today's date and a date should not be greater than today. The problem, however, the data type for the date is string, not date date...
2
by: boyhiso | last post by:
Hi, I'm new in this...is there are someone know the data type for ISBN and year ?
6
by: dkyadav80 | last post by:
Hi guys, I have a form in html , all description below: first: name of persion (input type box) second: job profile (input type box) third: experience from: list box (Month : Jan, Feb,.....
6
by: gozdeata | last post by:
hey there, i m trying to get only time information of a date type variable. i got a column in type of char, it keeps time info in hh:mm format - 5 characters when i tried to convert it to date...
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: 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: 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
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
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
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,...

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.