[{"id":"bcb0874d-299b-448e-9552-9e9b25ef80dd","tags":[{"product":null,"links":null,"id":"ba7e818e-4f6b-4211-b1ac-58e3bafcf439","name":"\u66F4\u65B0","color":"orange","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8ce3627e-9e58-471b-9133-4f135d191e7b","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"ae60ae59-34f5-4f32-a8eb-243ed1457543","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3d4848c3-910f-4ffa-9153-60bb507334a9","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"133f4ca6-d951-4d65-a618-3dc6301266f7","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"de62ec1c-813e-40b1-8160-a4cd109afe64","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2426c71d-8332-4cbd-a436-1ec4f8666464","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2ce7b6b0-78aa-4e4b-bf8a-e4ba2f988298","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"4706db46-0811-4652-8f59-1e0a1da84758","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"8f1271bb-2cd9-4f39-9897-c15b239ee7ab","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"677e13a7-6f3e-449f-986c-2c3a26f8d54f","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"5e40f6dc-caec-49d7-a1d0-be65f06815ba","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"2457f0e0-9e71-4860-a87d-065e0fb84f84","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5c67fd0-1145-482c-9113-97b492c44c18","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"a609a8fa-ab91-4c1d-a1c3-d209d0463303","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"b4a9eb15-94e5-48df-b218-a24138f0cf9c","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
        
(Showing Draft Content)

DateAdd函数示例-获取月末日期_SQLite日期转换

函数概述

语法:DateAdd(<时间单位>, <增减数值>, <日期时间表达式>)

说明:返回一个日期值增减一个指定单位时间间隔的结果。如DataAdd("d",-1,"2017-1-1")表示在2017-1-1基础上增加-1天,返回值为"2016-12-31"。

示例:{DateAdd("d", 5, SaleDate)}; {DateAdd(DateInterval.Day, 5, SaleDate)}

以下分别为您介绍如何使用 DateAdd 函数获取月末日期以及进行 SQLite 日期转换。

操作示例一 月末日期

报表应用中经常需要制作月报,月报就需要取到整个月的数据,即从月初第一天到月末最后一天的所有业务数据。而数据库中的日期往往带有具体时间,这就容易造成最后一天的数据遗漏。

为了避免这种情况的发生,我们经常需要用次月的首日减一天来得到当月的月末日期。

我们以今天为例,看一下具体的实现方法:

首先得到“ 次月首日 ”: {DateAdd("M", 1, DateSerial(Year(Today()), Month(Today()), 1))}

然后用“ 次月首日 ”减一天得到我们需要的“ 月末日期 ”: {DateAdd("d", -1, DateAdd("M", 1, DateSerial(Year(Today()), Month(Today()), 1)))}

image2020-10-13_11-7-31.png

image2020-10-13_11-8-32.png

操作示例二 SQLite日期转换

SQLite数据库中的日期时间字段值存储为一个浮点数,例如:43425.455467963。

其含义为:

  • 整数部分为自1899-12-30的天数

  • 小数部分为自凌晨0点的天数,0.5即中午12点整

为了便于阅读,我们可以使用表达式将其显转换为 yyyy-MM-dd HH:mm:ss 形式。

我们以下图中的SQLite字段值为例,介绍如何进行SQLite日期字段值的转换。

image2019-5-16_11-47-7.png

实现分析:

  • ADate”字段只有整数部分,那我们只需要转换天数即可。使用 {DateAdd("d",ADate,"1899-12-30") }

  • FGC_Create Date”字段由整数部分和小数部分组成,我们需要转换天数以及时分秒数。使用{DateAdd("s", (FGC_CreateDate-Floor(FGC_CreateDate))*24*60*60, DateAdd("d",Floor(FGC_CreateDate),"1899-12-30") )}。

实际应用中,您可以参考套用以上两个表达式。

使用这两个表达式进行转换后,效果如下。

image2019-5-16_11-58-10.png