【发布时间】:2009-11-03 06:13:09
【问题描述】:
使用 VB.NET 和 SQL Server 2005
我想根据给定的Outtime生成一个日期,
我正在输入类似的值
ID Date Intime Outtime Holiday
001 23-02-2009 08:00:00 17:00:00 no
001 24-02-2009 17:00:00 08:00:00 no
001 25-02-2009 10:00:00 16:00:00 no
001 26-02-2009 18:00:00 20:00:00 no
001 27-02-2009 yes
预期输出
表1
ID Date Intime Outtime DateIn Dateout
001 23-02-2009 08:00:00 17:00:00 23-02-2009 23-02-2009
001 24-02-2009 17:00:00 08:00:00 24-02-2009 25-02-2009
001 25-02-2009 10:00:00 16:00:00 25-02-2009 25-02-2009
001 26-02-2009 18:00:00 20:00:00 26-02-2009 27-02-2009
001 27-02-2009 - - - -
…,
从上表中,DateIn 列值应显示相同的日期列值,但 Dateout 列应根据 Outtime 显示。
In a first row – Intime is 08:00:00 and Outtime is 17:00:00, So Dateout should display the same date
In a second row – Intime is 17:00:00 and Outtime is 08:00:00, So DateOut should display the next day date.
In a third row – Intime is 10:00:00 and Outtime is 16:00:00, so Dateout should display the same date
In a fourth row – Intime is 18:00:00 and Outtime is 21:00:00, so Dateout should display the next day date.
In a fifth row – Holiday column value is yes, so it should not display any value in DateIn and DateOut
Dateout 列应该比较 Intime 和 Outtime 的值,如果 Outtime 小于 Intime,Dateout 列应该显示第二天的日期。
如果Holiday = Yes 那么它应该显示为一个空白列
对于上述情况,如何进行sql查询?
是否可以在vb.net中,哪个是更快的sql查询或vb.net代码?
上述条件需要 SQL 查询或 VB.NET 代码。
【问题讨论】:
标签: sql sql-server vb.net sql-server-2005