10.1 Get the date N days after the date specified
Find the date N days after the specified date.
Get orders where the goods are delivered within two days and arrive in three days after delivery in the year 2015. Below is the Orders table:
ID | CustomerID | OrderDate | DeliveryDate | ArrivalDate | Amount |
---|---|---|---|---|---|
10248 | VINET | 2012/07/04 | 2012/07/16 | 2012/08/01 | 428.0 |
10249 | TOMSP | 2012/07/05 | 2012/07/10 | 2012/08/16 | 1842.0 |
10250 | HANAR | 2012/07/08 | 2012/07/12 | 2012/08/05 | 1523.5 |
10251 | VICTE | 2012/07/08 | 2012/07/15 | 2012/08/05 | 624.95 |
10252 | SUPRD | 2012/07/09 | 2012/07/11 | 2012/08/06 | 3559.5 |
… | … | … | … | … | … |
SPL uses date + n to get the date N days after a certain date.
SPL script:
A | |
---|---|
1 | =connect(“db”) |
2 | =A1.query@x(“select * from Orders”) |
3 | =A2.select(year(OrderDate)==2015 && OrderDate+1>=DeliveryDate && DeliveryDate+3>=ArrivalDate) |
A1 Connect to the database.
A2 Import Orders table.
A3 Use operator “+” to calculate the date n days after the specified date.
Execution result:
ID | CustomerID | OrderDate | DeliveryDate | ArrivalDate | Amount |
---|---|---|---|---|---|
11094 | BERGS | 2015/07/18 | 2015/07/18 | 2015/07/19 | 506.05 |
11101 | AROUT | 2015/07/18 | 2015/07/18 | 2015/07/20 | 130.0 |
11102 | AROUT | 2015/07/18 | 2015/07/19 | 2015/07/20 | 240.0 |
… | … | … | … | … | … |
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL