Skip to content
Loading
  • Kapil Gaur
    0
    Amit is right. If you want some formatted date then you will get in string form only else DateTime object is having date and time both. When you do DateTime.Date => an string. You can anyway format DateTime.ToString() to the format you want.
    0
  • 0
    Convert your string to DateTime and then use DateTime.ToString("yyyy-MM-dd")
     
    DateTime dt= DateTime.ParseExact(inDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
    string str = dt.ToString("yyyy-MM-dd");
     
    More on C# DateTime:
    http://csharp.net-informations.com/language/date.htm
    0
  • Suraj Kumar
    -1
    You can acheive using SQL Server as shown below
    1. select Convert(Date,convert(varchar, getdate(), 23))  
    You can also get it using C#, check the below post
     
    https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1 
    -1
  • -1
    try this code
    1. string DateString = "11/12/2009";  
    2. IFormatProvider culture = new CultureInfo("en-US", true);  
    3. DateTime dateVal = DateTime.ParseExact(DateString, "yyyy-MM-dd", culture);  
    -1