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

Input Date Is Between 2 DB Date Records

A MS-Access DB table has 2 columns - StartTime & EndTime. Though the
data type of both the columns are Date/Time, the records under these 2
columns stores ONLY the TIME part & NOT the DATE part (for e.g.
7:00:00 AM, 2:00:00 PM, 8:35:00 PM etc.).

A Form in a ASP page has 3 dropdown lists. The 1st one is to select an
hour option, the 2nd one to select a minute option (this dropdown list
has only 4 options - 00, 15, 30, 45). The 3rd dropdown list is for
users to select AM or PM.

When users post the Form, how do I find out if the time entered in the
Form by users comes in between the StartTime & EndTime records that is
stored in the Access DB table & show a message to users accordingly?

For e.g. assume that one of the StarTime & EndTime records in the DB
table is, say, 8:00:00 AM & 10:00:00 AM respectively. Using the Form,
a user posts the time as 9:15 AM. Since 9:15 AM comes between 8:00:00
AM & 10:00:00 AM, then the user should be shown a message asking him
to re-enter the time in the Form since the time he posted is between
8:00:00 AM & 10:00:00 AM.

But if a user enters the time in the Form as, say, 2:00 PM, then he
should be allowed to proceed to the next step. Note that if a user
enters the time in the Form as 10:00:00 AM, then also he should be
allowed to proceed to the next step.

Thanks,

RON

May 13 '07 #1
3 1926

I'm not sure that this will work but try to use the vbscript "datediff"
function

--
dutiano
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

May 14 '07 #2
rn**@rediffmail.com wrote:
A MS-Access DB table has 2 columns - StartTime & EndTime. Though the
data type of both the columns are Date/Time, the records under these 2
columns stores ONLY the TIME part & NOT the DATE part (for e.g.
7:00:00 AM, 2:00:00 PM, 8:35:00 PM etc.).

A Form in a ASP page has 3 dropdown lists. The 1st one is to select an
hour option, the 2nd one to select a minute option (this dropdown list
has only 4 options - 00, 15, 30, 45). The 3rd dropdown list is for
users to select AM or PM.

When users post the Form, how do I find out if the time entered in the
Form by users comes in between the StartTime & EndTime records that is
stored in the Access DB table & show a message to users accordingly?

For e.g. assume that one of the StarTime & EndTime records in the DB
table is, say, 8:00:00 AM & 10:00:00 AM respectively. Using the Form,
a user posts the time as 9:15 AM. Since 9:15 AM comes between 8:00:00
AM & 10:00:00 AM, then the user should be shown a message asking him
to re-enter the time in the Form since the time he posted is between
8:00:00 AM & 10:00:00 AM.

But if a user enters the time in the Form as, say, 2:00 PM, then he
should be allowed to proceed to the next step. Note that if a user
enters the time in the Form as 10:00:00 AM, then also he should be
allowed to proceed to the next step.
I think the following will work
<%
timeposted = request.form("time")
on error resume next
timeposted=cdate(timeposted)
if err <0 then
'open a db connection using a variable called conn
sql="select count(*) from ... where " & _
"? between StartTime and EndTime"
set cmd=createobject("adodb.command")
cmd.commandtext=sql
cmd.commandtype=1 'adCmdText
set cmd.activeconnection = conn
set rs=cmd.execute(,array(timeposted))
if clng(rs(0).value) 1 then
response.write "Time slot in use"
else
'continue
end if
else
response.write "Invalid Time entered"
end if

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
May 14 '07 #3
Bob Barrows [MVP] wrote:
if clng(rs(0).value) 1 then
I meant to type:

if clng(rs(0).value) 0 then
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
May 14 '07 #4

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

Similar topics

17
by: Lapchien | last post by:
My table has a record called date/time - filled (not surprisingly) with a date and time. I can format the date in one query field, also the time, using format in an expression. My user wants me...
3
by: David Kuhn | last post by:
I have a query with a date field criteria of: Between And When the query is run, I am asked for the Start date and then the End Date. So far, so good. The records returned are all those in...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
2
by: Riegn Man | last post by:
I have a problem with access and our time clocks. We have time clocks that put out a .log file with the badge swipes for everybody. There is one .log file for each day. I am pulling that data...
10
by: Kenneth | last post by:
I have a Query that consist of a lot of different sales data, and one of the colums are different date. The date goes from 1jan2003 til 31jan2003. in this Query I only want the salesdata for...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
8
by: Trev | last post by:
Hi Can anyone point me in the right direction here, I would like to open a table in access 2003 by date. I have an asp web page which needs to read data from a table with each days today's date...
2
by: wevans | last post by:
I have 3 tables, Customer, Offsite Service and service. I need to create a sales report/query based on the results of the user input, which is a date range. I've got it working great with two of the...
5
by: sara | last post by:
Hi - I have had this problem MANY times and I just don't think I have the best solution. I am running a parameter query to retrieve records where work was completed between 2 dates. The...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.