怎样在sql中实现哪?
select * from stuinfo where datetime>2002-2-2
怎么不能执行

解决方案 »

  1.   

    .NET Framework 类库   DateTime.Compare 方法请参见
    DateTime 结构 | DateTime 成员 | System 命名空间 | CompareTo | Equals | DateTime 成员(Visual J# 语法) | C++ 托管扩展编程 
    要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准
    语言
    C#C++JScriptVisual Basic全部显示
    比较 DateTime 的两个实例,并返回它们相对值的指示。[Visual Basic]
    Public Shared Function Compare( _
       ByVal t1 As DateTime, _
       ByVal t2 As DateTime _
    ) As Integer[C#]
    public static int Compare(
       DateTime t1,
       DateTime t2
    );[C++]
    public: static int Compare(
       DateTime t1,
       DateTime t2
    );[JScript]
    public static function Compare(
       t1 : DateTime,
       t2 : DateTime
    ) : int;参数
    t1 
    第一个 DateTime。 
    t2 
    第二个 DateTime。 
    返回值
    表示 t1 和 t2 的相对值的有符号的数字。值类型 条件 
    小于零 t1 小于 t2。 
    零 t1 等于 t2。 
    大于零 t1 大于 t2。 示例
    下面的示例说明 Compare。[Visual Basic] 
    Dim t1 As New DateTime(100)
    Dim t2 As New DateTime(20)If DateTime.Compare(t1, t2) > 0 Then
        Console.WriteLine("t1 > t2")
    End If
    If DateTime.Compare(t1, t2) = 0 Then
        Console.WriteLine("t1 == t2")
    End If
    If DateTime.Compare(t1, t2) < 0 Then
        Console.WriteLine("t1 < t2")
    End If[C#] 
    DateTime t1 = new DateTime(100);
    DateTime t2 = new DateTime(20);if (DateTime.Compare(t1, t2) >  0) Console.WriteLine("t1 > t2"); 
    if (DateTime.Compare(t1, t2) == 0) Console.WriteLine("t1 == t2"); 
    if (DateTime.Compare(t1, t2) <  0) Console.WriteLine("t1 < t2");[C++]  DateTime t1(100);
     DateTime t2(20);
     
     if (DateTime::Compare(t1, t2) >  0) Console::WriteLine("t1 > t2"); 
     if (DateTime::Compare(t1, t2) == 0) Console::WriteLine("t1 == t2"); 
     if (DateTime::Compare(t1, t2) <  0) Console::WriteLine("t1 < t2");[JScript] 
    var t1 : DateTime = new DateTime(100);
    var t2 : DateTime = new DateTime(20);if (DateTime.Compare(t1, t2) >  0) Console.WriteLine("t1 > t2"); 
    if (DateTime.Compare(t1, t2) == 0) Console.WriteLine("t1 == t2"); 
    if (DateTime.Compare(t1, t2) <  0) Console.WriteLine("t1 < t2");要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版 - Windows CE .NET, 公共语言基础结构 (CLI) 标准请参见
    DateTime 结构 | DateTime 成员 | System 命名空间 | CompareTo | Equals | DateTime 成员(Visual J# 语法) | C++ 托管扩展编程 
    --------------------------------------------------------------------------------发送有关此主题的意见 &copy; 2001-2002 Microsoft Corporation。保留所有权利。 
      

  2.   

    楼上强^^select * from stuinfo where datetime>2002-2-2
    怎么不能执行因为datetime
    你这里的datetime是变量名吗?跟SQL中的数据类型名冲突(SQL有叫datetime型的类型)
    你可以改成
    select * from stuinfo where [datetime] > '2002-02-02'加[]号,还有,日期要加'',作为字符传给SQL,让它自动帮你转日期型,否则结果很有趣,可以看看^^