急:怎样在SQL Server中只选择日期?
想在titles表中只获取pubdate的年月日,
并且保证取出的字段仍然是日期型的,我该怎么做?
一般的选取如下:
1> select distinct pubdate from titles
2> go
pubdate
-----------------------
1991-06-09 00:00:00.000
1991-06-12 00:00:00.000
1991-06-15 00:00:00.000
1991-06-18 00:00:00.000
1991-06-22 00:00:00.000
1991-06-30 00:00:00.000
1991-10-05 00:00:00.000
1991-10-21 00:00:00.000
1994-06-12 00:00:00.000
2000-08-06 01:33:54.123
2000-08-06 01:33:54.140
而我只想要2000-08-06这样不带时间的格式
问题点数:20、回复次数:8Top
1 楼cj8()回复于 2005-04-01 10:54:07 得分 0
你看看这个
http://dev.csdn.net/develop/article/50/50225.shtmTop
2 楼cj8()回复于 2005-04-01 11:07:25 得分 0
可以用format(pubdate,"yy-MM-dd")Top
3 楼rain911(死神)回复于 2005-04-01 11:21:16 得分 10
或者可以SQL改成
select distinct Convert(char(10),pubdate,111) pubdate from titlesTop
4 楼YangYuWeb(飘邈...)回复于 2005-04-01 11:22:31 得分 10
select distinct convert(varchar(10),pubdate,120) as pubdate from titlesTop
5 楼zwxrain(Lilo)回复于 2005-05-04 09:01:54 得分 0
select distinct convert(varchar(10),pubdate,121) as pubdate from titlesTop
6 楼swzlxm(守望者)回复于 2005-05-04 10:23:08 得分 0
convertTop
7 楼ILearnCSharp(欲速则不达,⊙_⊙)回复于 2005-05-04 10:42:13 得分 0
select distinct convert(varchar(10),pubdate,120) as pubdate from titles
好
Top
8 楼ILearnCSharp(欲速则不达,⊙_⊙)回复于 2005-05-04 10:49:24 得分 0
你是否要用到程序里呢?Top




