web 2.0

VB.NET & DateDiff()

VB.NET & DateDiff() - DateDiff() : Returns a Long value specifying the number of time intervals between two Date values.

ShotDev Focus:
- VB.NET & DateDiff()

Syntax


DateDiff(DateInterval,Date1,Date2)

DateInterval


DateInterval.Day
DateInterval.DayOfYear
DateInterval.Hour
DateInterval.Minute
DateInterval.Month
DateInterval.Quarter
DateInterval.Second
DateInterval.Weekday
DateInterval.WeekOfYear
DateInterval.Year

Example

DateDiff.aspx

<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Session.LCID = 1033
Me.lblText1.Text  = DateDiff(DateInterval.Day, Cdate("11/08/2008"),Cdate("11/09/2008"))
Me.lblText2.Text  = DateDiff(DateInterval.Month, Cdate("11/08/2008"), Cdate("12/08/2008"))
Me.lblText3.Text  = DateDiff(DateInterval.Year, Cdate("11/08/2008"), Cdate("11/08/2009"))
Me.lblText4.Text  = DateDiff(DateInterval.Hour, Cdate("11/08/2008 09:00"), Cdate("11/08/2008 10:00"))
Me.lblText5.Text  = DateDiff(DateInterval.Second, Cdate("09:00:45"), Cdate("09:00:50"))
Me.lblText6.Text  = DateDiff(DateInterval.Minute, Cdate("09:00"), Cdate("09:10"))
End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form runat="server">
<asp:Label id="lblText1" runat="server"></asp:Label><br />
<asp:Label id="lblText2" runat="server"></asp:Label><br />
<asp:Label id="lblText3" runat="server"></asp:Label><br />
<asp:Label id="lblText4" runat="server"></asp:Label><br />
<asp:Label id="lblText5" runat="server"></asp:Label><br />
<asp:Label id="lblText6" runat="server"></asp:Label><br />
</form>
</body>
</html>

Screenshot

VB.NET & DateDiff()
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

One Response to “VB.NET & DateDiff()”

  1. 1guidance…

Leave a Reply

You must be logged in to post a comment.