2012年5月28日 星期一

日期相減算出-天,小時,分

Dim STime As Date = "2005/11/8" Dim ETime As Date = "2005/12/28" Response.Write(ETime & "-" & STime) 

Response.Write("")

 Dim Total As TimeSpan = ETime.Subtract(STime) Response.Write("共幾天:") Response.Write(Total.Days.ToString()) 
Response.Write("")
 Response.Write("共幾小時") Response.Write(Total.Hours.ToString())
 Response.Write("") 
Response.Write("共幾分:") Response.Write(Total.Minutes.ToString()) 
Response.Write("") 
Response.Write("總共多少天 :") Response.Write(Total.TotalDays.ToString()) 
Response.Write("") 
Response.Write("總共多少小時 :") Response.Write(Total.TotalHours.ToString()) 
Response.Write("") 
Response.Write("總共多少秒:") Response.Write(Total.TotalSeconds.ToString())