Home » Posts tagged "Time"

Archive for the 'Time' Tag

Month, day and year code behind format

Day name and date format of Friday, 11/11/2011 Dim strDayName As String Dim curTime As New DateTime curTime = DateTime.Now.ToShortDateString() strDayName = curTime.DayOfWeek.ToString Response.Write(strDayName & “, ” & DateTime.Today) Result: Friday, 11/11/2011 Day name and date format of Friday, 11/11/2011 using case funtion Dim iDay As String Dim strDayName As String iDay = DatePart(“w”, DateTime.Now) […]

VB.NET – Date in code behind

Here is example of how we can define date in code behind: Current month name ‘ – label text for current month (e.i. September) CMonthLbl.Text = “Current month is ” & MonthName(Date.Now.Month).ToString() ‘ – label <asp:label ID=”CMonthLbl” runat=”server”> ‘ – output Current month is September Other examples: Any month name ‘ – your favorite month […]

VB.NET date and time format

Date as Monday, August 29, 2011 Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim dd As Date = Date.Today label1.Text = String.Format(“{0:dddd, MMMM d, yyyy}”, dd) End Sub Other formats… ‘ – month/day numbers without/with leading zeroes String.Format(“{0:M/d/yyyy}”, dt); ‘ “8/29/2011” String.Format(“{0:MM/dd/yyyy}”, dt); ‘ “08/29/2011” ‘ – day/month names String.Format(“{0:ddd, MMM d, […]