Results 1 to 7 of 7

Thread: Display Date Without the Time

  1. #1

    Thread Starter
    Lively Member adsc's Avatar
    Join Date
    Nov 2002
    Location
    Kuwait
    Posts
    71

    Display Date Without the Time

    I am trying to display the date from SQL server database into a window form textbox as "dd/MM/yyyy", but it shows the time also.

    Any idea how to avoide this.

    Thanks for the help
    <><><><><><><><><><><><><><><><><><>
    <><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
    <><><><><><><><><><><><><><><><><><>

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Posts
    88
    use the formatdatetime() or the format()

    for example

    textbox1.text = formatdatetime(dteDateandTime, DateFormat.ShortDate)

    or

    textbox1.text = format(dteDateandTime, "MM/dd/yyyy")

  3. #3

    Thread Starter
    Lively Member adsc's Avatar
    Join Date
    Nov 2002
    Location
    Kuwait
    Posts
    71
    Databinding removes the format !!

    Me.txtRegDate.DataBindings.Add("Text", myDS.Tables("Member"), "RegDate")
    <><><><><><><><><><><><><><><><><><>
    <><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
    <><><><><><><><><><><><><><><><><><>

  4. #4
    Lively Member
    Join Date
    Nov 1999
    Posts
    88
    in cases like this, i have traditionally modified my sql statement to return a string representation of the date i want to look at. the problem with this approach, however, is if you try to sort by that column, its sorted by the string, not the date. i have been looking for a way around this, but still havent found one. sorry.

  5. #5

    Thread Starter
    Lively Member adsc's Avatar
    Join Date
    Nov 2002
    Location
    Kuwait
    Posts
    71
    Thank u for your help
    <><><><><><><><><><><><><><><><><><>
    <><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
    <><><><><><><><><><><><><><><><><><>

  6. #6

    Thread Starter
    Lively Member adsc's Avatar
    Join Date
    Nov 2002
    Location
    Kuwait
    Posts
    71

    Thumbs up

    dwhawley,

    This solves the problem perfectly, look at the Format and Parse events.
    http://msdn.microsoft.com/library/de...ormattopic.asp




    Originally posted by dwhawley
    in cases like this, i have traditionally modified my sql statement to return a string representation of the date i want to look at. the problem with this approach, however, is if you try to sort by that column, its sorted by the string, not the date. i have been looking for a way around this, but still havent found one. sorry.
    <><><><><><><><><><><><><><><><><><>
    <><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
    <><><><><><><><><><><><><><><><><><>

  7. #7
    Lively Member
    Join Date
    Nov 1999
    Posts
    88

    Thumbs up

    nice find and thanks for the return message. my issue has been formatting values within a datagrid and it appears that this is how you do it


    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width