System.DateTime dt;
dt.ToShortDateString;

解决方案 »

  1.   

    Dim d As Date
            '....
            d.ToShortDateString()        Format(d, "yy-MM-DD")
      

  2.   

    怎么样把日期型变量的时分秒去掉呀
    //DataTime t=DataNow();
    t.ToString("YYYYMMDD");就可以
      

  3.   

    public static void Main(string[] args)  {
           DateTime dt = DateTime.Now;
           String[] format = {
               "d", "D",
               "f", "F",
               "g", "G",
               "m",
               "r",
               "s",
               "t", "T",
               "u", "U",
               "y",
               "dddd, MMMM dd yyyy",
               "ddd, MMM d \"'\"yy",
               "dddd, MMMM dd",
               "M/yy",
               "dd-MM-yy",
           };
           String date;
           for (int i = 0; i < format.Length; i++) {
               date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
               Console.WriteLine(String.Concat(format[i], " :" , date));
           }
    可以把时间转换成任意你想要的格式。
      

  4.   

    using System.Globalization;
      

  5.   

    select convert(char(10),getdate(),120) --2003-03-13
    select convert(char(8),getdate(),112) --20030313
    两者都可以
      

  6.   

    System.DateTime dt;dt.ToShortDateString;
      

  7.   

    system.DateTime.Now.ToString("yyyy-MM-dd");