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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Dates

Author  Topic 

Pete_N
Posting Yak Master

181 Posts

Posted - 2013-03-06 : 06:09:53
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

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-03-06 : 06:39:11
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

Cheers
MIK
Go to Top of Page

Pete_N
Posting Yak Master

181 Posts

Posted - 2013-03-06 : 07:13:24
Hi,

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-06 : 11:43:04
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
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -