我怎样才能按日期排序在MS Access 2007?

编程入门 行业动态 更新时间:2024-10-28 15:19:33
本文介绍了我怎样才能按日期排序在MS Access 2007?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

只是想知道我怎么排序文本列,显示日期格式mm / dd / YYYY数据。

Just want to know how do I sort a text column that shows data in date format mm/dd/yyyy.

推荐答案

您必须首先转换为日期以获得适当的排序。这是将Datetext到RealDate,然后排序在该列(字段)的查询。您也可以点击标题,选择排序顺序。

You will first have to convert to a date to get a proper sort. This is a query that converts Datetext to RealDate, and then sorts on that column (field). You can also click the header to choose the sort order.

SELECT t.ID, t.Datetext, DateSerial(Mid([Datetext],InStrRev([Datetext],"/")+1), Mid([Datetext],1,InStr([Datetext],"/")-1), Mid([Datetext],InStr([Datetext],"/")+1, (InStrRev(Datetext,"/")-InStr([Datetext],"/"))-1)) AS RealDate FROM Table t Order By 3

您可以使用IIF避免零错误:

You can use IIf to avoid errors from null:

IIf([Datetext] Is Null,Null,DateSerial( Mid([Datetext],InStrRev([Datetext],"/")+1), Mid([Datetext],1,InStr([Datetext],"/")-1), Mid([Datetext],InStr([Datetext],"/")+1, (InStrRev(Datetext,"/")-InStr([Datetext],"/"))-1))) AS RealDate

更多推荐

我怎样才能按日期排序在MS Access 2007?

本文发布于:2023-06-10 05:47:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/608262.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按日   MS   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!