可以肯定一点就是用getdate()函数插入的时间为 年月日+时分秒。
问1:可以把时间改为“年月日”吗?(示例数据库Northwing的日期项就是这样)
问2:在C#下定义 DateTime time=DateTime.Now;,格式也是 年月日+时分秒 ,有没办法改为“年月日”。不用tostrig()方法,因为这样会改变time的类型,不利于查询。
问3:SQL语句 :“select * from UsersTable  where CreatedDate=time ”的条件应该怎样写
(其中UsersTable为数据库中的用户表,CreatedDate为用户表中的一个域)大家可以给出例子吗??

解决方案 »

  1.   

    where CreateDate>'2005-3-11' and CreateDate<'2005-3-12'
    这样可以
      

  2.   

    where datename(year,CreateDate)=2005 and datename(month,CreateDate)=3 and datename(day,CreateDate)=11这样,可以取 2005-3-11号的记录
      

  3.   

    1:select convert(char(10),getdate(),120) as Date
    2:DateTime.Now.ToShortDateString();
    3:where CreatedDatebetween '2005-3-11' and '2005-3-12'
      

  4.   

    3:where CreatedDate between '2005-3-11' and '2005-3-12'