Friday, December 12, 2008

Date Formatting in VB.Net

Lets take the following example to know all the possible Date formatting in VB.Net.

CODE:

Dim op As New StringBuilder
Dim currerntDate As Date = Date.Now
op.AppendLine("Date Format Example)
op.AppendLine("Day in integer : " + Format(currerntDate, "dd") )
op.AppendLine("Day in string : " + Format(currerntDate, "dddd"))
op.AppendLine("Month in integer : " + Format(currerntDate, "MM"))
op.AppendLine("Month in string : " + Format(currerntDate, "MMMM"))
op.AppendLine("Year in integer : " + Format(currerntDate, "yy"))
op.AppendLine("Year in integer : " + Format(currerntDate, "yyyy"))
Response.Write(op)

OUTPUT

Date Format Example

Day in integer : 11
Day in string : Thursday
Month in integer: 12
Month in string : December
Year in integer : 08
Year in integer : 2008

No comments:

Post a Comment