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 2005 Forums
 Transact-SQL (2005)
 Need Help in Where Class

Author  Topic 

khanewal
Starting Member

33 Posts

Posted - 2010-07-26 : 20:41:27
HI Friends,

I am sure you will help me to fix my problem, Actually my Question is:

I have two Date colum in two tables in two different database, as per format:

Format-1: 2010-07-22 09:42:52.647

Format-2: 22/07/2010 9:42:53 AM

Actually I am using query to compare these two values, so first I need to round off "miliseconds" for Format - 1 and then convert format as per Format -2 and use in where class, I am not sure how to use in where class, but I know how to round milisecond and convert the format as find below.

Rounding:

select DATEADD(ms,ROUND(DATEDIFF(ms,DATEADD(day,DATEDIFF(day,0,abc),0),abc ),-3),DATEADD(day,DATEDIFF(day,0,abc),0))
FROM cde..table1

Conversion:

select convert(varchar(30),abc,103)+' '+convert(varchar,datepart(hh,abc))+':'
+convert(varchar,datepart(mi,abc))+':'+convert(varchar,datepart(ss,abc))+' '+right(abc,2)
FROM cde..table1


Can you please help me out

many thanks,

khanewal
Starting Member

33 Posts

Posted - 2010-07-26 : 22:41:15
NO body reply me, Anyway thanks, I found the solution
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-26 : 22:44:04
what is the data type for these 2 date column ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -