ASP.NET DateAdd() ใช้ในการเพิ่ม/ลบเวลาตามต้องการ
Syntax
DateAdd(DateInterval,Number,DateValue)
DateInterval
DateInterval.Day
DateInterval.DayOfYear
DateInterval.Hour
DateInterval.Minute
DateInterval.Month
DateInterval.Quarter
DateInterval.Second
DateInterval.Weekday
DateInterval.WeekOfYear
DateInterval.Year
Sample
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim strDate As Date
strDate = "10/11/2008"
Me.lblText1.Text = DateAdd(DateInterval.Day, 1, Date.Now)
Me.lblText2.Text = DateAdd(DateInterval.Month, 1, Date.Now)
Me.lblText3.Text = DateAdd(DateInterval.Year, 1, Date.Now)
Me.lblText4.Text = DateAdd(DateInterval.Hour, 1, Date.Now)
Me.lblText5.Text = DateAdd(DateInterval.Second, 1, Date.Now)
Me.lblText6.Text = DateAdd(DateInterval.Minute, 1, strDate)
End Sub
</script>
<html>
<head>
</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
Property & Method (Others Related) |
|