Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Extracting only date and suppressing time in C#

From DateTime format we can get only date.

  1. using System;
  2.  
  3. namespace forgetCode
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. DateTime dt = DateTime.Now;
  11.  
  12. string dateonly = dt.ToShortDateString();
  13.  
  14. Console.WriteLine(dateonly);
  15. }
  16.  
  17. }
  18. }


Output:
21-07-2012

..