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

Help with a Time array

Hi there, I need to create a list (diary style) of times in a day. I can do
this with normal "metricated" break-up of the hours, but need to display the
actual time.

I have a "Starting time" and an ending time as variables. I also have a
"Timespan" for the increment.
For example Start time=8:00 AM
End Time 6:00 PM and increment in 30 minute intervals

I need to convert anything after the decimal point into Minutes. If I have
"11.5" I want to show it as "11.30". I can divide the decimal into 60 to
give me the Minute equivalent of the decimal, but need to do this without
affecting the "Hour"
The start time, end time and increments will be a variable from a database.
Any help will be much appreciated.

Thanks
Hans

Jul 19 '05 #1
4 1351
If the variable is a string eg. "11.5" you could use string manipulation
i.e. Left(), Right(), indexOf() to find the certain parts of the value. then
make the calculations on the relevant parts and concatenate the two strings,
to display the time.
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
Hi there, I need to create a list (diary style) of times in a day. I can do this with normal "metricated" break-up of the hours, but need to display the actual time.

I have a "Starting time" and an ending time as variables. I also have a
"Timespan" for the increment.
For example Start time=8:00 AM
End Time 6:00 PM and increment in 30 minute intervals

I need to convert anything after the decimal point into Minutes. If I have
"11.5" I want to show it as "11.30". I can divide the decimal into 60 to
give me the Minute equivalent of the decimal, but need to do this without
affecting the "Hour"
The start time, end time and increments will be a variable from a database. Any help will be much appreciated.

Thanks
Hans

Jul 19 '05 #2
Thanks Alex,

Not too sure what you mean here, I am testing it with a form to see if it
works OK, the code is as follows:
<%
AppTime=60
If Request("App_Time")<>"" then
AppTime =Request("App_Time")
end if
AppBrk=AppTime/60

AppStart=9
If Request("StartTime")<>"" then
AppStart =Request("StartTime")
end if
AppEnd=6
If Request.Form("End_Time")<>"" then
AppEnd =Request.Form("End_Time")
end if
%>

<%
hourCounter = AppStart
Do WHILE hourCounter < 12 %>

Hours: <%Response.Write(hourCounter)%> - AM<br>
<% hourCounter = hourCounter + AppBrk
Loop
%>
<%
PMCounter = 0
Do WHILE PMCounter <= AppEnd-AppBrk %>

Hours:
<% If PMCounter<1 Then
Response.Write (PMCounter+12)
else Response.Write(PMCounter)
end if%> - PM<br>
<% PMCounter = PMCounter + AppBrk
Loop
%>

How would I use your suggestion?

Thanks

Hans

"Alex Goodey" <ag*****@hsfinancial.co.uk> wrote in message
news:bu************@ID-221525.news.uni-berlin.de...
If the variable is a string eg. "11.5" you could use string manipulation
i.e. Left(), Right(), indexOf() to find the certain parts of the value. then make the calculations on the relevant parts and concatenate the two strings, to display the time.
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
Hi there, I need to create a list (diary style) of times in a day. I can

do
this with normal "metricated" break-up of the hours, but need to display

the
actual time.

I have a "Starting time" and an ending time as variables. I also have a
"Timespan" for the increment.
For example Start time=8:00 AM
End Time 6:00 PM and increment in 30 minute intervals

I need to convert anything after the decimal point into Minutes. If I have "11.5" I want to show it as "11.30". I can divide the decimal into 60 to
give me the Minute equivalent of the decimal, but need to do this without affecting the "Hour"
The start time, end time and increments will be a variable from a

database.
Any help will be much appreciated.

Thanks
Hans


Jul 19 '05 #3
Try this, oh and i meant the InStr() function not indexOf()

<%
AppTime=60
If Request("App_Time")<>"" then
AppTime =Request("App_Time")
end if
AppBrk=AppTime/60

AppStart=9
If Request("StartTime")<>"" then
AppStart =Request("StartTime")
end if
AppEnd=6
If Request.Form("End_Time")<>"" then
AppEnd =Request.Form("End_Time")
end if
%>

<%
hourCounter = AppStart
AppBrk = 0.5
Do WHILE hourCounter < 12 %>

Hours:
<%
intPosDot = inStr(hourCounter, ".")
if intPosDot = 0 then
Response.Write(hourCounter)
else
strHour = Left(hourCounter, intPosDot-1)
strMinute = Right(hourCounter, len(hourCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if

%>

- AM<br>
<% hourCounter = hourCounter + AppBrk
Loop
%>
<%
PMCounter = 0
Do WHILE PMCounter <= AppEnd-AppBrk %>

Hours:
<% If PMCounter<1 Then
intPosDot = inStr(PMCounter, ".")
if intPosDot = 0 then
Response.Write (PMCounter+12)
else
strHour = Left(PMCounter, intPosDot-1)
strMinute = Right(PMCounter, len(PMCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if
else
intPosDot = inStr(PMCounter, ".")
if intPosDot = 0 then
Response.Write(PMCounter)
else
strHour = Left(PMCounter, intPosDot-1)
strMinute = Right(PMCounter, len(PMCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if
end if%> - PM<br>
<% PMCounter = PMCounter + AppBrk
Loop
%>
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
Thanks Alex,

Not too sure what you mean here, I am testing it with a form to see if it
works OK, the code is as follows:
<%
AppTime=60
If Request("App_Time")<>"" then
AppTime =Request("App_Time")
end if
AppBrk=AppTime/60

AppStart=9
If Request("StartTime")<>"" then
AppStart =Request("StartTime")
end if
AppEnd=6
If Request.Form("End_Time")<>"" then
AppEnd =Request.Form("End_Time")
end if
%>

<%
hourCounter = AppStart
Do WHILE hourCounter < 12 %>

Hours: <%Response.Write(hourCounter)%> - AM<br>
<% hourCounter = hourCounter + AppBrk
Loop
%>
<%
PMCounter = 0
Do WHILE PMCounter <= AppEnd-AppBrk %>

Hours:
<% If PMCounter<1 Then
Response.Write (PMCounter+12)
else Response.Write(PMCounter)
end if%> - PM<br>
<% PMCounter = PMCounter + AppBrk
Loop
%>

How would I use your suggestion?

Thanks

Hans

"Alex Goodey" <ag*****@hsfinancial.co.uk> wrote in message
news:bu************@ID-221525.news.uni-berlin.de...
If the variable is a string eg. "11.5" you could use string manipulation
i.e. Left(), Right(), indexOf() to find the certain parts of the value.

then
make the calculations on the relevant parts and concatenate the two

strings,
to display the time.
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
Hi there, I need to create a list (diary style) of times in a day. I can
do
this with normal "metricated" break-up of the hours, but need to
display
the
actual time.

I have a "Starting time" and an ending time as variables. I also have

a "Timespan" for the increment.
For example Start time=8:00 AM
End Time 6:00 PM and increment in 30 minute intervals

I need to convert anything after the decimal point into Minutes. If I

have "11.5" I want to show it as "11.30". I can divide the decimal into 60 to give me the Minute equivalent of the decimal, but need to do this without affecting the "Hour"
The start time, end time and increments will be a variable from a

database.
Any help will be much appreciated.

Thanks
Hans



Jul 19 '05 #4
Thanks Alex, I will give it a go and let you know if it works OK.

Hans

"Alex Goodey" <ag*****@hsfinancial.co.uk> wrote in message
news:bu************@ID-221525.news.uni-berlin.de...
Try this, oh and i meant the InStr() function not indexOf()

<%
AppTime=60
If Request("App_Time")<>"" then
AppTime =Request("App_Time")
end if
AppBrk=AppTime/60

AppStart=9
If Request("StartTime")<>"" then
AppStart =Request("StartTime")
end if
AppEnd=6
If Request.Form("End_Time")<>"" then
AppEnd =Request.Form("End_Time")
end if
%>

<%
hourCounter = AppStart
AppBrk = 0.5
Do WHILE hourCounter < 12 %>

Hours:
<%
intPosDot = inStr(hourCounter, ".")
if intPosDot = 0 then
Response.Write(hourCounter)
else
strHour = Left(hourCounter, intPosDot-1)
strMinute = Right(hourCounter, len(hourCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if

%>

- AM<br>
<% hourCounter = hourCounter + AppBrk
Loop
%>
<%
PMCounter = 0
Do WHILE PMCounter <= AppEnd-AppBrk %>

Hours:
<% If PMCounter<1 Then
intPosDot = inStr(PMCounter, ".")
if intPosDot = 0 then
Response.Write (PMCounter+12)
else
strHour = Left(PMCounter, intPosDot-1)
strMinute = Right(PMCounter, len(PMCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if
else
intPosDot = inStr(PMCounter, ".")
if intPosDot = 0 then
Response.Write(PMCounter)
else
strHour = Left(PMCounter, intPosDot-1)
strMinute = Right(PMCounter, len(PMCounter)-intPosDot)
strMinute = "0." & strMinute
strMinute = 60 * strMinute
Response.Write(strHour & ":" & strMinute)
end if
end if%> - PM<br>
<% PMCounter = PMCounter + AppBrk
Loop
%>
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
Thanks Alex,

Not too sure what you mean here, I am testing it with a form to see if it
works OK, the code is as follows:
<%
AppTime=60
If Request("App_Time")<>"" then
AppTime =Request("App_Time")
end if
AppBrk=AppTime/60

AppStart=9
If Request("StartTime")<>"" then
AppStart =Request("StartTime")
end if
AppEnd=6
If Request.Form("End_Time")<>"" then
AppEnd =Request.Form("End_Time")
end if
%>

<%
hourCounter = AppStart
Do WHILE hourCounter < 12 %>

Hours: <%Response.Write(hourCounter)%> - AM<br>
<% hourCounter = hourCounter + AppBrk
Loop
%>
<%
PMCounter = 0
Do WHILE PMCounter <= AppEnd-AppBrk %>

Hours:
<% If PMCounter<1 Then
Response.Write (PMCounter+12)
else Response.Write(PMCounter)
end if%> - PM<br>
<% PMCounter = PMCounter + AppBrk
Loop
%>

How would I use your suggestion?

Thanks

Hans

"Alex Goodey" <ag*****@hsfinancial.co.uk> wrote in message
news:bu************@ID-221525.news.uni-berlin.de...
If the variable is a string eg. "11.5" you could use string manipulation i.e. Left(), Right(), indexOf() to find the certain parts of the
value. then
make the calculations on the relevant parts and concatenate the two strings,
to display the time.
"Hans" <Ha**@home.com> wrote in message
news:bu**********@ctb-nnrp2.saix.net...
> Hi there, I need to create a list (diary style) of times in a day. I can do
> this with normal "metricated" break-up of the hours, but need to display the
> actual time.
>
> I have a "Starting time" and an ending time as variables. I also
have a > "Timespan" for the increment.
> For example Start time=8:00 AM
> End Time 6:00 PM and increment in 30 minute intervals
>
> I need to convert anything after the decimal point into Minutes. If
I have
> "11.5" I want to show it as "11.30". I can divide the decimal into
60 to > give me the Minute equivalent of the decimal, but need to do this

without
> affecting the "Hour"
> The start time, end time and increments will be a variable from a
database.
> Any help will be much appreciated.
>
> Thanks
> Hans
>
>
>



Jul 19 '05 #5

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

Similar topics

4
by: KellyH | last post by:
Hi, I hope someone can point me in the right direction. I'll get it out of the way: Yes, I am a college student. No, I am not looking for anyone to do my homework, just looking for help. I have...
3
by: ash | last post by:
Hey I am new, but I don't have time to intruduce myself yet. I am intro to C++ and this is a programme I have to write. all the direction are here, It will be very nice of someone to figure this...
5
by: coinjo | last post by:
Problem Statement One of the local banks is gearing up for a big advertising campaign and would like to see how long its customers are waiting for service by teller/service provider at drive-up...
1
by: foker | last post by:
I have a file with a list of times in it in the form hh:mm:ss. The file starts with a single INT like 460. That int is the number of times in the file so I can size my dynamic array correctly. I...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: rajashekharthota | last post by:
HI all, Can any one help me here these are my assignments i am new to C++. Pls help find solution to these 1.Suppose that each row of an nxn array A consists of 1's and 0's such...
1
Bugsy1937
by: Bugsy1937 | last post by:
Hello Folks, I wrote the following long ago and it worked for years. It Still works in IE, but can't get it to work in Firefox3. Here's the script, hope someone can help me: <html> <body>...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.