Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
partap26
Starting Member
27 Posts |
Posted - 2013-05-28 : 05:24:18
|
SELECT cast(a.po_date As Date) as podate, cast(a.supply_date As Date) as sddate,CASE WHEN supply_date IS NULL THEN '00/00/0000' ENDFROM device_order a INNER JOIN customer_details b ON a.customer_name = b.customer_nameThe output ispo_date | No column name | sdate2013-05-14 | 2013-05-23 | NULL2013-05-17 | NULL | 00/00/00002013-05-17 | NULL | 00/00/00002013-05-14 | NULL | 00/00/0000But i wantpo_date | sdate 2013-05-14 | 2013-05-23 2013-05-17 | 00/00/0000 2013-05-17 | 00/00/0000 2013-05-14 | 00/00/0000How to do this????? |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2013-05-28 : 05:28:06
|
Note : Assuming supply_date is varchar columnSELECT cast(a.po_date As Date) as podate, CASE WHEN supply_date IS NULLTHEN '00/00/0000' else supply_date END as sdateFROM device_order a INNER JOIN customer_details b ON a.customer_name = b.customer_nameSenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
|
|
partap26
Starting Member
27 Posts |
Posted - 2013-05-28 : 05:30:47
|
Conversion failed when converting date and/or time from character string for this query |
|
|
partap26
Starting Member
27 Posts |
Posted - 2013-05-28 : 05:33:34
|
NO assumption please.. supply_date , po_date are date columns |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2013-05-28 : 05:37:24
|
hope this will workSELECT cast(a.po_date As Date) as podate, CASE WHEN supply_date IS NULLTHEN '00/00/0000' else cast(supply_date as varchar(50))END as sdateFROM device_order a INNER JOIN customer_details b ON a.customer_name = b.customer_nameSenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
|
|
partap26
Starting Member
27 Posts |
Posted - 2013-05-28 : 05:44:56
|
This is 100% accurate |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-28 : 05:56:25
|
why not this?SELECT cast(a.po_date As Date) as podate, COALESCE(supply_date,'0000-00-00') as sdateFROM device_order a INNER JOIN customer_details b ON a.customer_name = b.customer_name ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|