Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

add 9 hours to actual value

Posted on 2005-04-02
12
Medium Priority
?
248 Views
Last Modified: 2010-04-07
Hi,

We have a drop down list that contains time value every half hour; so there are 48 total items.
items are :
00:00:00
00:30:00
01:00:00
01:30:00
02:00:00
02:30:00
03:00:00
03:30:00
04:00:00
04:30:00
05:00:00
05:30:00
06:00:00
06:30:00
07:00:00
07:30:00
08:00:00
08:30:00
09:00:00
09:30:00
10:00:00
10:30:00
11:00:00
11:30:00
12:00:00
12:30:00
13:00:00
13:30:00
14:00:00
14:30:00
15:00:00
15:30:00
16:00:00
16:30:00
17:00:00
17:30:00
18:00:00
18:30:00
19:00:00
19:30:00
20:00:00
20:30:00
21:00:00
21:30:00
22:00:00
22:30:00
23:00:00
23:30:00

How can we add 9 hours to the selected item in the drop down list and place it on a textbox1.text ?
i.e.
23:30 + 9 hours = 08:30

set auto post back on DDL and textbox1 ?
and on click DDL event place some code..

Please kindly guide me in what code to place in asp.net vb

Thanks.
0
Comment
Question by:lynnton
  • 7
  • 5
12 Comments
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13687211
You can add 9 hours with the DateAdd function:

DateAdd("h", 9, datetimeVar)
0
 
LVL 1

Author Comment

by:lynnton
ID: 13687220
leew,

Will it work on

23:30:00 ?

I was thinking it would add a date value, which we don't need..

Thanks.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13687232
Drop the date value.  Add the 9 hours, then use TimeValue(datetimevar) to just take the time value.  Please test this before you accept as an answer.
0
 
LVL 1

Author Comment

by:lynnton
ID: 13687240
leew,

How are you?
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13687245
Ummm... ok?  Seems an odd question given the topic... we know each other?
0
 
LVL 1

Author Comment

by:lynnton
ID: 13687289
leew,

You always post on my question, sad, you dont even remember names of people.

it work great, unfortunately, it wa in this format 8:00:00 AM

The system time format is in 00:00:00

Please kindly guide me to change the format

    txtend1.text=format("h:n:s",timevalue(dateadd("h",9,ddlday1.selecteditem.text)))

Thanks.
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13687323
Sorry, in most cases, I don't remember names of people unless they've done something to otherwise annoy me.  I probably participate in 40-60 questions a day, on average...

I'm a little confused... the ddlday1.selecteditem.text was in the format 8:00:00 AM?  Or the result was?  Which format do you want it in?  (Sorry it's late for me so no all neurons are firing appropriately).
0
 
LVL 1

Author Comment

by:lynnton
ID: 13687329
leew,

txtend1.text is getting 9:00:00 AM/PM format.

How can we change it to 00:00:00

Thanks.
0
 
LVL 97

Accepted Solution

by:
Lee W, MVP earned 2000 total points
ID: 13687371
There may well be a function that will do this, but I'm not sure what it is.  I'd write one:

'Remember to define your variables used below; ADateTimeValue, Hr, Mn, Sc

Function TimeTo24(ADateTimeValue)
   Hr = Hour(ADateTimeValue)
   Mn = Minute(ADateTimeValue)
   Sc = Second(ADateTimeValue)
   TimeTo24 = CStr(Hr) & ":" & CStr(Mn) & ":" & CStr(Sc)
End Function

Then modify the following line:

txtend1.text=timeto24(timevalue(dateadd("h",9,ddlday1.selecteditem.text)))
0
 
LVL 1

Author Comment

by:lynnton
ID: 13687459
leew,

Thanks so much for you time and patience, is it possible if you could glance on this link?

http://experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21373911.html
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13687484
Sorry, wish I could help you on that one - that's using lots of .net stuff and I'm VERY weak on .NET specific things at the moment.  Best of luck.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question