blay
blay

Reputation: 225

Calculating days, hours and minutes difference using asp.vb

I wan to know who to calculation days, hours and minutes difference in asp. Since i'm new to it its somehow difficult for me. here my code

<%

Dim cdate, ddate

cdate = "9/27/2013 4:35:00 PM"

ddate = "9/30/2013 9:35:00 PM"


%>

please how do i find the difference between these two dates. precisely days left, hours left and minutes remaining

Upvotes: 0

Views: 1502

Answers (1)

John
John

Reputation: 1327

Use DateDiff:

fromDate="31-Jan-09 00:00:00"
toDate="31-Jan-10 23:59:00"

document.write(DateDiff("yyyy",fromDate,toDate) & "<br />")
document.write(DateDiff("q",fromDate,toDate) & "<br />")
document.write(DateDiff("m",fromDate,toDate) & "<br />")
document.write(DateDiff("y",fromDate,toDate) & "<br />")
document.write(DateDiff("d",fromDate,toDate) & "<br />")
document.write(DateDiff("w",fromDate,toDate) & "<br />")
document.write(DateDiff("ww",fromDate,toDate) & "<br />")
document.write(DateDiff("h",fromDate,toDate) & "<br />")
document.write(DateDiff("n",fromDate,toDate) & "<br />")
document.write(DateDiff("s",fromDate,toDate) & "<br />")

see this link for the documentation: http://www.w3schools.com/vbscript/func_datediff.asp

Upvotes: 1

Related Questions