Click here to Skip to main content
15,887,910 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
VB
objTimeSpent = DateTime.Now.Subtract(ViewState("StartTime"))
Posted
Updated 5-Sep-11 21:17pm
v2
Comments
Prerak Patel 6-Sep-11 3:17am    
What is problem?
nagendrathecoder 6-Sep-11 3:21am    
What you want is not clear to us.
Please explain your question and give details.

Without the explicit error messge to go on, I can only suggest that you need to cast ViewState("StartTime") to a DateTime before you use it.
 
Share this answer
 
Comments
Abhijit Jana 6-Sep-11 3:30am    
+5. Agree.
What I understood from your question is, you have some date time value in view state and you want to subtract it from current time.
var timespan = DateTime.Now.Subtract((DateTime)ViewState["DateTime"])


You must need to check the ViewState for null or valid date time value. Else you will get exception.
To know more about the DateTime check here[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900