Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

181 Posts

Posted - 03/06/2013 :  06:09:53  Show Profile  Reply with Quote
I have two tables both with smalldatetime fields

Select MyTime from Table1.dbo.Test returns '2010-01-28'
Select MyTime from Table2.dbo.Test returns '2010-28-01'

what is the query to return Table1,dbo.test back as 2010-28-01 and I need to do date comparasions between data in the two tables

Flowing Fount of Yak Knowledge

1054 Posts

Posted - 03/06/2013 :  06:39:11  Show Profile  Reply with Quote
table1.dbo.test, Is table1 is Schema? If no - its a table, then how come it executed?

when both tables are having "smalldatetime" fields then how those columns hvae returned the date in two different formats? Not possible in my openion with SQL server. SQL server dates data type stores data in the format of YYYY-MM-DD


Edited by - MIK_2008 on 03/06/2013 06:39:41
Go to Top of Page

Posting Yak Master

181 Posts

Posted - 03/06/2013 :  07:13:24  Show Profile  Reply with Quote

I have sorted it. one of the tables was loaded by importing a XML file. The text date was applied to a function but when converting into the table I was using
CONVERT( SMALLDATETIME, (SELECT SQLProcesses.dbo.func_ProcessingDate_To_ClearedFundsDate(g.c.value('(@uhl1ProcessingDate)','varchar(32) ' ))), 103),

instead of

CONVERT( SMALLDATETIME, (SELECT SQLProcesses.dbo.func_ProcessingDate_To_ClearedFundsDate(g.c.value('(@uhl1ProcessingDate)','varchar(32) ' ))), 120),

It's always helps to bounce some problems off people , it focuses the mind and thing become clearer

Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 03/06/2013 :  11:43:04  Show Profile  Reply with Quote
whatever you're telling doesnt make any sense
120 gives yyyy-mm-dd
which will be 2010-01-28
and 103 will give it in dd/mm/yyyy format

ie 28/01/2010

2010-28-01 is not a valid date format in SQL server

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000