Access中datepart、dateserial、datediff函数

 时间:2024-10-12 13:16:19

1、打开查询设计分别使用datepart、dateserial、datediff函数进行表达式的书写。仍收墩芬蓥然采用表1的时间数据进行操作:(”年: DatePart("yyyy",[时间])-1“、”月: DatePart("m",[时间])-1“、”日: DatePart("d",[时间])-1“、“新日期: DateSerial([年],[月],[日])”、”差距: DateDiff("m",[新日期],[时间])“);具体如图

Access中datepart、dateserial、datediff函数
Access中datepart、dateserial、datediff函数
Access中datepart、dateserial、datediff函数
Access中datepart、dateserial、datediff函数
Access中datepart、dateserial、datediff函数
Access中datepart、dateserial、datediff函数

2、运行结果并查看核对。如图我们发现日期有0的,但是用dateserial运行之后自动变成了上个月的31号;

Access中datepart、dateserial、datediff函数

3、SQL语句如下:SELECT 表1.时间, 表1.姓名, 表1.数量, DatePart("yyyy",[时间])-1 AS 年, DatePart("m",[时间])-1 AS 月, DatePart("d",[时间])-1 AS 日, DateSerial([年],[月],[日]) AS 新日期, DateDiff("m",[新日期],[时间]) AS 差距FROM 表1;

  • Access中字段连接运算
  • Access中追加查询的设计方法
  • Access如何使用查找重复项查询向导
  • Win版Access2019如何替换表格内容?
  • Access中如何创建按钮式宏
  • 热门搜索
    新春手抄报 说好普通话手抄报 植树节手抄报一等奖 爱成都迎大运手抄报 学生手抄报 网络安全手抄报简单漂亮 端午节的手抄报 简单又漂亮 母亲节手抄报内容 关于科学的手抄报 书法手抄报