碰上一个比较麻烦的问题。
数据库里存的是这种格式“04:05”
查询时输入的是多少多少“秒”
如果要比较数据库里的值与输入值的大小应该怎么转。

解决方案 »

  1.   

            int time = 130;//130秒
            
            TimeSpan ts = DateTime.Now.AddSeconds(time) - DateTime.Now;
            string strs = string.Format("{0}天{1}小时{2}分{3}秒", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);你要的分钟的格式自己获取
    string time=ts.Minutes+":"+ts.Seconds;
      

  2.   

    Select datediff(ss,'1900-01-01','1900-01-01 00:'+ '04:05')
    如果要与输入的秒做为比较条件,可以这么写
      

  3.   

    Select * From table WHere Select datediff(ss,'1900-01-01','1900-01-01 00:'+ [时间])<=[多少秒]
    or
    Select * From table WHere Select datediff(ss,'1900-01-01','1900-01-01 00:'+ [时间])>=[多少秒]
      

  4.   

    strSql += " and [FileInfo].[voicelength] >=" + Int32.Parse(tbVoice.Text.Trim()) * 60;
    我现在tbVoice.Text里是输入了多少秒,这个还怎么比较呢?
      

  5.   

    strSql += " and datediff(ss,'1900-01-01','1900-01-01 00:'+ [FileInfo].[voicelength]) >=" + Int32.Parse(tbVoice.Text.Trim()) * 60;
      

  6.   


    你这个Select datediff(ss,'1900-01-01','1900-01-01 00:'+ '04:05')
    放在where 后面查出来的是一串数字,如“04:05”查出来是245,这个在where 后面比较语法不对撒。
      

  7.   


    你这个Select datediff(ss,'1900-01-01','1900-01-01 00:'+ '04:05')
    放在where 后面查出来的是一串数字,如“04:05”查出来是245,这个在where 后面比较语法不对撒。
    ???
    datediff(ss,'1900-01-01','1900-01-01 00:'+ '04:05')
    这个是一内部函数,与Select有关吗?我这么写只是想让你知道可以这么用
      

  8.   

    可以了,我这里数据有null,去除null就可以了。给分了,谢谢各位