CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    177

    Convert DateTime to String

    Hi, I had retrieve the data from SQL Server where the DateTime format in SQL Server is yyyy-MM-dd HH:mm:ss. How can I using C# code to change the DateTime format to yyyy-MM-dd???

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Convert DateTime to String

    What type is the data returned from server? If it is DateTime, use simlpy ToString("yyyy-MM-dd"). Otherwise, you would have to convertr it to DateTime first. Look at Convert.ToDateTime() or DateTime.Parse().
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

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

Featured