从数据库里读出来的"2007/12/19 0:00:00"
我想取这个字符串表示年月日的部分“2007/12/19”,不要时间的部分,用哪个函数啊

解决方案 »

  1.   


    string dstring = "2007/12/19 0:00:00";
    Response.Write(dstring.Substring(0,dstring.IndexOf(' ')));
      

  2.   

    这是另外一种方法:
    string str= "2007/12/19 0:00:00";
    Console.WriteLine(Convert.ToDateTime(str).ToShortDateString());
      

  3.   

    Convert.ToDateTime(str).ToShortDateString()
      

  4.   

    SELECT CONVERT ( nvarchar(20), 字段名,111 ) FROM 表名
      

  5.   

    sql convert函数的一些参数http://www.cnblogs.com/Vegaslee/archive/2007/12/10/989811.html
      

  6.   

       DateTime dt = DateTime.Now;        string str = dt.ToString("yyyy/MM/dd");
            this.dt1.Text = str.Replace('-', '/');
      

  7.   

    http://blog.csdn.net/xianfajushi/archive/2009/09/19/4570876.aspx
      

  8.   

    datetime.now.tostring(yy年MM月dd日)
      

  9.   

    "2007/12/19 0:00:00".Substring(0,10)
      

  10.   

    Convert.ToDateTime(str).ToString("yyyy/mm/dd");
      

  11.   

    DateTime.Today().ToLongDateString()
    得出今天的年月日
      

  12.   

    C#中datetime的使用
    http://www.xunxt.com/forum.php?mod=viewthread&tid=66&fromuid=1
      

  13.   

    select convert(char(10),DateCreate,120) from tablename
     
    DateCreate是日期字段
      

  14.   

    tostring可以进行format
    toshortdatestring可以
    sql,convert函数可以
    不过有时间服务器有时候会时格式2011/3/23
    最好他们得出后,再次的.replace()