sql server datetime 按天 group

很多数据都是按 datetime 记录的时间, 这样想按天 group 的时候就很麻烦
现在我们很多代码中都是用 left 取前10位,然后再 cast 成 datetime ,然后再 group ,效率很低
今天查了资料才知道,其实 sql server 的 convert  就内置了这个转换过程, 方法如下:

select CONVERT(varchar(10), getDate(),120) --不要时间2002-1-1
select convert(char(8),getdate(),112) ----20020101
select convert(char(8),getdate(),108)  ---06:05:05

101 美国 mm/dd/yyyy
2 102 ANSI yy.mm.dd
3 103 英国/法国 dd/mm/yy
4 104 德国 dd.mm.yy
5 105 意大利 dd-mm-yy
6 106 - dd mon yy
7 107 - mon dd, yy
8 108 - hh:mm:ss
- 9 或 109 (*)  默认值 + 毫秒 mon dd yyyy hh:mi:ss:mmmAM(或 PM)
10 110 美国 mm-dd-yy
11 111 日本 yy/mm/dd
12 112 ISO yymmdd
- 13 或 113 (*)  欧洲默认值 + 毫秒 dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 或 120 (*)  ODBC 规范 yyyy-mm-dd hh:mm:ss[.fff]
- 21 或 121 (*)  ODBC 规范(带毫秒) yyyy-mm-dd hh:mm:ss[.fff]
- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(不含空格)
- 130* 科威特 dd mon yyyy hh:mi:ss:mmmAM
- 131* 科威特 dd/mm/yy hh:mi:ss:mmmAM

Print | posted on Tuesday, December 19, 2006 4:17 PM

Feedback


# Buy cialis. 7/12/2007 3:57 PM Cialis.

Cod phentermine as well as cialis cheap reviews. Cialis.


# Stores that carry ephedra diet products. 9/8/2007 11:33 AM Ephedra.

Products containing ephedra. Ephedra yellow jackets. Colorado ephedra attorney. Diet pills with ephedra. Ephedra.


# Tramadol sr 100. 9/9/2007 11:02 AM Tramadol.

Comparative potencies of opioids tramadol. Lowest price tramadol. Snorting tramadol. Tramadol. Tramadol drug concerns.


# Re viagra cello. 9/10/2007 11:13 AM Viagra.

Viagra. Buy viagra online. Female viagra. Viagra sales uk. How does viagra work.


# Phentermine without a prescription. 11/18/2007 11:23 PM Phentermine no prescription outside us.

Phentermine without prescription. Phentermine no prescription. Buy no phentermine prescription. Phentermine 37.5 no prescription needed.


Gravatar

# re: sql server datetime 按天 group 7/9/2008 7:21 AM antibiotic pharmacy

antibiotic pharmacy, antibiotic drugs, buy zithromax, buy amoxil, buy bactrim, buy biaxin, buy ceclor, buy cipro


Gravatar

# re: sql server datetime 按天 group 8/15/2008 11:23 PM viagra overseas

Very good job. Add your blog to bookmarks. There are many valuable and useful ideas that I have to apply in
practice. But still need time to reflect on the information. Even now, when after reading the text of your post,
when I write a comment, I think of these things, I feel that now entirely on other species.
JEx that today - a good day.


Gravatar

# re: sql server datetime 按天 group 8/21/2008 3:56 PM Dogs training

Very good job. Add your blog to bookmarks. There are many valuable and useful ideas that I have to apply in
practice.


Gravatar

# re: sql server datetime 按天 group 8/26/2008 6:41 AM music artists

RGMPr3.com is dedicated to provide its visitors the best mp3 search engine on the net.
You can listen any mp3 file before you download it, also select popular songs from our various top mp3 charts.


 re: sql server datetime 按天 group 9/22/2008 5:43 PM a

what ahout group by month??


Gravatar

# re: sql server datetime 按天 group 11/7/2008 6:08 PM buy propecia

Sorry, Philippe, forgot to thank you for a great preview. Thanks for stepping in at such short notice!

Title  
Name  
Email
Url
Comments   
Please add 4 and 1 and type the answer here: