使用Access DB查询以获取年份中的日期和月份 [英] query to get date and month from year using Access DB

查看:163
本文介绍了使用Access DB查询以获取年份中的日期和月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一列日期,它是日期,月,年的组合,例如2012年6月21日.
现在我想从该列(21/6)中提取日期和月份,并将其放在Date1的单个列中.如何获取它?

I have a column Date in DB which is a combination of date,month,year like 21/6/2012.
Now I want to extract the date and month from that column (21/6)and should get that in a single column Date1.How can i get it ?

推荐答案

Access根据系统的日期时间格式处理日期,这与SQL SERVER像yyyy-mm-dd
一样使用日期时间格式进行处理
要执行您需要的操作,请使用以下查询

Access handles dates according to the date time format of your system unlike SQL SERVER which uses it like yyyy-mm-dd

To do what you need use the following query

SELECT Str(Datepart("d",datecolumn))+'/'+Str(Datepart("m",datecolumn)) AS Expr1
FROM tablename
WHERE (((tablename.[id])=4));



根据需要修改条件

祝您好运.........



Modify where condition according to your needs

Best of luck.........


使用此查询,它将在我检查访问权限后起作用.

use this query it will work i have checked it on access.

SELECT str(datepart("d",Start_date)) +'/'+ str(datepart("m",Start_date))
FROM tblwork



您也可以使用此查询



and you can use this query also

SELECT mid( format(Start_date,'dd/MM/yyyy'),1,5)
FROM tblwork
WHERE len(Start_date)>0;


亲爱的sandeep,

我已经在SQL Server 2005中进行了此查询,请在Access DB中运行此查询并查看结果.将
Dear sandeep,

I had made this query in SQL Server 2005, please run this query in Access DB and see the result.. I think following query will work. replace
getdate()

替换为您的date 字段.


with your date field.


select rtrim(convert(char,month(getdate())))+ '/' + rtrim(convert(char,day(getdate())))




谢谢
灰烬




Thanks
Ashish


这篇关于使用Access DB查询以获取年份中的日期和月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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