C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » VB.NET Syntax »

FormatDateTime function in VB.NET


Posted Date: 01 Oct 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: RekhaMember Level: Gold    
Rating: 1 out of 5Points: 10



The FormatDateTime function returns a formatted string representation for a date and/or time. The syntax is:

FormatPercent(expression [, format] )

Where:

expression
The numeric expression to format

format
A date/time formatting value



Expression Result

FormatDateTime(Now, DateFormat.GeneralDate) 10/01/2008 10:55:06 AM
FormatDateTime(Now, DateFormat.LongDate) Thursday, October 1, 2008
FormatDateTime(Now, DateFormat.ShortDate) 10/01/2008
FormatDateTime(Now, DateFormat.LongTime) 10:55:06 AM
FormatDateTime(Now, DateFormat.ShortTime) 10:55

This example uses the following code to display value in a TextBox.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Dim txt As String

txt &= "FormatDateTime(Now, DateFormat.GeneralDate) = " _
& FormatDateTime(Now, DateFormat.GeneralDate) & _
vbCrLf
txt &= "FormatDateTime(Now, DateFormat.LongDate) = " & _
FormatDateTime(Now, DateFormat.LongDate) & vbCrLf
txt &= "FormatDateTime(Now, DateFormat.ShortDate) = " & _
FormatDateTime(Now, DateFormat.ShortDate) & vbCrLf
txt &= "FormatDateTime(Now, DateFormat.LongTime) = " & _
FormatDateTime(Now, DateFormat.LongTime) & vbCrLf
txt &= "FormatDateTime(Now, DateFormat.ShortTime) = " & _
FormatDateTime(Now, DateFormat.ShortTime) & vbCrLf

txtResult.Text = txt
txtResult.Select(0, 0)
End Sub



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Time format in vb.net  .  Date time format vb.net  .  Date time format in vb.net  .  Date format in .net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Simple Note Pad Like Application
Previous Resource: Creating Database Using VB.Net
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use