clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1130830 fiddles created (16569 in the last week).

create table "INVAB" ( 編號 float, 品號 varchar(255), 庫別 varchar(255), 出貨日 varchar(255) );
 hidden batch(es)


insert into "INVAB" values (1,'1101','T1','20180801'), (2,'1102','T2','20180701'), (3,'1103','T3','20180301'), (4,'1104','T4','20180102');
4 rows affected
 hidden batch(es)


select * from "INVAB"
編號 品號 庫別 出貨日
1 1101 T1 20180801
2 1102 T2 20180701
3 1103 T3 20180301
4 1104 T4 20180102
 hidden batch(es)


select *, convert(varchar,cast(DATEADD(month,6,CONVERT(date,出貨日)) as date),111) "最大出貨日+半年", convert(varchar,cast(CONVERT(date,'20190101') as date),111) "設定日期" from "INVAB" where DATEADD(month,6,CONVERT(date,出貨日)) < CONVERT(date,'20190101')
編號 品號 庫別 出貨日 最大出貨日+半年 設定日期
3 1103 T3 20180301 2018/09/01 2019/01/01
4 1104 T4 20180102 2018/07/02 2019/01/01
 hidden batch(es)