Link to home
Start Free TrialLog in
Avatar of lynnton
lynnton

asked on

add 9 hours to actual value

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.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

You can add 9 hours with the DateAdd function:

DateAdd("h", 9, datetimeVar)
Avatar of lynnton
lynnton

ASKER

leew,

Will it work on

23:30:00 ?

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

Thanks.
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.
Avatar of lynnton

ASKER

leew,

How are you?
Ummm... ok?  Seems an odd question given the topic... we know each other?
Avatar of lynnton

ASKER

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.
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).
Avatar of lynnton

ASKER

leew,

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

How can we change it to 00:00:00

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lynnton

ASKER

leew,

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

https://www.experts-exchange.com/questions/21373911/Error-object-is-not-a-member-of-'ASP-shiftent-aspx'.html
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.