0
使用SQL Server 2005如何生成日期
Tabl1
ID Date Intime Outtime
001 20101201 080000 180000
001 20101202 210000 060000
001 20101203 180000 090000
001 20101204 100000 170000
....
。
Date Datatype is nvarchar
Intime, Outtime datatype is nvarchar
Intime, Outtime Format: HHMMSS
从table1中,我想再创建一个名称为NextDate的列名称。 下一个日期栏应该用下面的条件
If Outtime is Greater than Intime then it should display the next date
If outtime is less than intime then it should display the same date
期望输出显示日期列的下一个日期
ID日期银泰Outtime NextDate
001 20101201 080000 180000 20101201 (Outtime is less than Intime)
001 20101202 210000 060000 20101203 (Outtime is greater than Intime)
001 20101203 180000 090000 20101204 (Outtime is greater than Intime)
001 20101204 100000 170000 20101204 (Outtime is less than Intime)
....
如何使一个查询上述条件。
需要查询帮助。
建议:如果您有日期,请将其设置为** DATETIME **列!你会比拥有varchar字段好得多...... – 2011-02-03 06:44:20