Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date field WITHOUT year & SEARCHING based on Dates/Time??

Status
Not open for further replies.

vasnas

Programmer
Jul 4, 2007
17
0
0
GR
hello! Im having trouble with the Date and Time fields in my db. I have a BeginDate and EndDate and BeginTime and EndTime fields indicating the working hours of hotels.

1] The first thing is: can i use ONLY day and month (for the date fields)? I have tried everything but i think Access absolutely requires the use of years (which is irrelavant for the business periods of hotels). If yes, please tell me the mask/format (or any other indirect way you can think of) as i have tried everything...

2] Secondly, how can i search (in my SearchForm) for a hotel based on a date or time range or a specific date/time? Any ideas about the code (im brand new to Access, and such code examples do not appear in my Access books). Any links to such online available code that could help?

Here's my SearchForm's code (eg. Searching for Company Name and Area - unbound text boxes...) to get an idea/in case you need it:

Private Sub cmdSearch_Click()
Dim sql As String
sql = "SELECT Company.CID, CompanyName, Area, DID, DepartmentName FROM QRY_Departments WHERE 1=1 "

If Me.txt_CompanyName.Value <> "" Then
sql = sql & " AND CompanyName LIKE '" & Me.txt_CompanyName.Value & "*'"
End If
If Me.txt_Area.Value <> "" Then
sql = sql & " AND Area LIKE '" & Me.txt_Area.Value & "*'"
...
Me.lst_Results.RowSource = sql
Me.lst_Results.Requery...

Thank you in advance for any help!!! (sorry for the long thread...)
Vas
 



hi,

First of all, Date/Time values are NUMBERS, like right now, in North Texas, the Date/Time value is 39329.63311, which can be FORMATTED to appear in any number of recognizable formats like 9/4/07 or 4 Sep 2007 or Tuesday September 4, 15:11 or... any number os ways.

The Date/Time value can be formatted to only display MONTH & DAY, like 09/04.

The Date./Time value can be CONVERTED to a STRING using the FORMAT function, like Format(Date,"mm-dd"), or Format(date,"mmm dd, ddd")

So worry not about the year. It is there and it MUST be there in order to work correctly.

Skip,
[sub]
[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top