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 »

Much Better LongDateTime() Function


Posted Date: 19 Sep 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: Hefin DsouzaMember Level: Diamond    
Rating: 1 out of 5Points: 10



This is MuchBetterLongDateTime Function which returns a String value of the given datetime object.

It also automatically adds a post fix of st to date.


Public Shared Function MuchBetterLongDateFormat(ByVal [date] As DateTime) As String

Dim day As Integer = [date].Day
Dim post As String
Select Case day
Case 1, 21, 31
post = " st ,"
Case 2, 22
post = " nd ,"
Case 3, 23
post = " rd "
Case Else
post = " th ,"
End Select
Dim month As String = ""

Select Case [date].Month
Case 1
month = " January "
Case 2
month = " February "
Case 3
month = " March "
Case 4
month = " April "
Case 5
month = " May "
Case 6
month = " June "
Case 7
month = " July "
Case 8
month = " August "
Case 9
month = " September "
Case 10
month = " October "
Case 11
month = " November "
Case 12
month = " December "
End Select


Return [date].Day & post & [date].DayOfWeek.ToString() & " ," & month & [date].Year

End Function


Usage is Simple

TextBox1.Text = ExtendDate.MuchBetterLongDateFormat(DateTime.Now)

================================================================================
Regards Hefin Dsouza
================================================================================
| DOWNLOAD SAMPLE BELOW |
================================================================================

Attachments

  • Download Sample (21351-19617-DateFun.rar)


  • 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.
    Datetime  .  

    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: Drag And Drop to Listbox and textbox
    Previous Resource: Creating Cookies 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