Access 2007 + C#数据等级 [英] Access 2007 + c# Data rank

查看:93
本文介绍了Access 2007 + C#数据等级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对数据格式有疑问
我尝试选择2个数据的等级
我尝试这种数据格式
yyyy/mm/dd
mm/dd/yyyy
dd/mm/yyyy
但没有一个是所有Windows machin都通用的
有人可以建议我最好的格式吗?thnx

hi i have problem with Data format
i try to select i rank of 2 data
i try this format of data
yyyy/mm/dd
mm/dd/yyyy
dd/mm/yyyy
but no one of this is universal for all windows machin
can some one suggest me how is the best format ?thnx

推荐答案

如果要在Access数据库中进行排序,则应使用DateTime列类型,数据库将为您进行适当的排序.

如果要在C#应用程序中进行排序,则DateTime结构具有比较运算符,可用于对订单日期进行排名.

您应该使用此结构(而不​​是字符串)来比较和排序日期.

如果要在列表或网格的一列中显示日期,则很可能可以将网格配置为接受该列中的DateTime对象(即,您不需要将DateTime转换为字符串;实际上,这可能会为您自动完成).网格可能会提供一种方法,您可以通过它配置DateTume的哪一部分实际显示给用户以及如何格式化,但是在后台,网格知道存储在列中的数据类型实际上是DateTime和因此知道如何正确地对其进行排序.

最重要的是:仅在最后一分钟将日期和时间转换为字符串;在转换为人类可读的形式之前,请使用强类型变量进行所有计算.

希望有帮助,
克里斯
If you''re doing the sorting in the access database, you should be using a DateTime column type, and the database will take care of proper sorting for you.

If you''re doing the sorting in your C# app, the DateTime structure has comparison operators that you can use to rank order dates.

You should use this structure, not strings, for comparing and sorting dates.

If you are displaying dates in a column in a list or grid, then it is likely that you can configure the grid to accept DateTime objects in that column (i.e. you do NOT need to convert the DateTime to a string; in fact, this may be done automatically for you). The grid will likely have a means by which you configure what part of the DateTume is actually shown to the user, and how it is formatted, but, behind the scenes, the grid knows that the datatype stored in the column is really a DateTime and therefore knows how to sort it properly.

The bottom line: only convert dates & times to strings at the very last minute; do all computing using a strongly typed variable before converting to a human readable form.

Hope that helps,
Chris


select *
from tabel
where tabel.data >= #dd/mm/yyyy# AND table.data <= #dd/mm/yyyy#



使用BETWEEN获取日期之间的数据.



use BETWEEN to get data between dates.

SELECT *
FROM tabel
WHERE tabel.data BETWEEN #dd/mm/yyyy# AND #dd/mm/yyyy#


这篇关于Access 2007 + C#数据等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆