如何在连接两个表时获得DateFormate(dd / MM / yyyy) [英] How to get DateFormate (dd/MM/yyyy) when joining two tables

查看:73
本文介绍了如何在连接两个表时获得DateFormate(dd / MM / yyyy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends



在内部联接的帮助下,我加入了两张表格

 选择 SR.amountpaid,SR。 date ,S.name 来自 SupplierRecord  as  SR  inner   join  Supplier  as  S  on  SR.Supplierid = S.Supplierid 其中 Purchaseid = '  0' 



在这次加入中,我得到一个如下时间的日期



金额日期名称

1000 2013-01-21 12: 30:18.000 Vishal

2000 2013-01-22 10:29:41.000 A Mandlekar



但我想要一个唯一的约会(即。 2013-01-21)将不是datewithtime(2013-01-21 12:30:18.000)。



所以你可以帮我吗。



thnx提前。

解决方案

您需要使用格式为23的CONVERT函数: http://www.sqlusa.com/bestpractices2005/centurydateformat/ [ ^ ]



 选择 
SR.amountpaid,
转换 varchar ,SR。 date 23 ),
S.name
来自 SupplierRecord as SR
内部 加入供应商 S SR.Supplierid = S.Sup plierid
其中 Purchaseid = ' 0'< /跨度>


Hello Friends

with the help of inner join,i joined two table like that

select SR.amountpaid,SR.date,S.name from SupplierRecord as SR inner join Supplier as S on SR.Supplierid=S.Supplierid where Purchaseid ='0'


in this joining i get a date with time like below

amountpaid date name
1000 2013-01-21 12:30:18.000 Vishal
2000 2013-01-22 10:29:41.000 A Mandlekar

but i want a only date (ie.2013-01-21 ) will be come not datewithtime (2013-01-21 12:30:18.000).

so can you please help me.

thnx in advance.

解决方案

You need to use the CONVERT function with format 23: http://www.sqlusa.com/bestpractices2005/centurydateformat/[^]

select 
  SR.amountpaid,
  convert(varchar, SR.date, 23),
  S.name 
from SupplierRecord as SR 
inner join Supplier as S on SR.Supplierid=S.Supplierid 
where Purchaseid ='0'


这篇关于如何在连接两个表时获得DateFormate(dd / MM / yyyy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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