sql = "select top 1  * from singlemoter where datetime>='" + startDate + "'and datetime<='" + endDate + "'";
startDate是2012-3-12这种格式的日期,我需要在datetime>=2012-3-12 00:00这种格式的日期,该如何增加呢?

解决方案 »

  1.   

    Convert.ToDateTime(startDate,"yyyy-MM-dd HH:mm"); 
      

  2.   

    你直接就将startDate直接后面加"00-00"可以么
      

  3.   

    用字符串吧,startDate=startDate+“ 00:00” 
      

  4.   

    要写个SQL里面的函数(名字忘了),把字符串转换为日期,然后在比较。
        这个最好弄成存储过程比较好
      

  5.   

    where datetime>='" + startDate + "'and datetime<='" + endDate + "'";像1楼那样重新组合字符串
      

  6.   

    date(ModifyTime,'start of day') 
      

  7.   


    sql = "select top 1 * from singlemoter where datetime>='" + startDate + " 00:00:01'and datetime<='" + endDate + " 23:59:59'";
    这样试试啊
      

  8.   


    把startDate和endDate先格式化一下然后再传入sql语句