如何从数据库检索数据
问题描述:
在我的数据库中,列字段的发布日期格式为"2010-05-03 11:59:37.640".
在此,我想仅使用日期检索数据.如何从数据库中获取数据.
请告诉我.
In my database the column field posteddate format is ''2010-05-03 11:59:37.640''.
In this I want to retreive the data using only date. How is it possible to get the data from the database.
Please tell me.
答
选择convert(varchar,getdate(),104)
您可以根据需要选择100到104之间的格式
&u可以将您的日期替换为getdate()
或像
这样写
选择convert(varchar,posteddate,104)
select convert(varchar,getdate(),104)
u can use format from 100 to 104 as per you choice
& u can put ur date in place of getdate()
or write like
select convert(varchar,posteddate,104)
要从db中检索数据,必须使用称为DML的SQL的一部分. /default.asp>网站以简单的方式说明sql
to retreive data from db must be used part of SQL called DML.. this site explains sql in simple way
选择convert(varchar,getdate(),104)
使用此功能,您将获得日期alon .....
select convert(varchar,getdate(),104)
Use this u will get date alon.....