February 28, 2006 at 7:22 am
Hi,
I have a date column,Date_A, from table_A in this format 2004-03-12 02:31:03.000
and another from table_B,Date_B, in this format 04/01/2006
I wish to joing the two table using the dates but want to disregard the seconds on Date_A.
select *
from
Table_A join Table_B on Date_A = Date_B
do I need to do a convert on the date with the seconds??
Any help welcome
Thanks in advance,
Eamon
February 28, 2006 at 7:38 am
Maybe what datatype is Date_A and what type is Date_B. If they are not the same type I suggest doing a cast. I would suggest doing like so personally
select *
from
Table_A join Table_B on
cast(Date_A as datetime) = cast(Date_B as datetime)
February 28, 2006 at 7:39 am
Yes, convert the date to the format you want - look on BOL for teh various formats. You may have to use the LEFT function as well to trim the seconds from the date.
Tryst
February 28, 2006 at 7:51 am
I suggest you cast only one of them, the one with the extended time information. You don't have to care about the format, since internally there's no difference in the storage.
_/_/_/ paramind _/_/_/
February 28, 2006 at 8:35 am
Guys,
I casted just one of then just to give me dd/mm/yyyy
I used convert and style 103.
Thanks,
Eamon
February 28, 2006 at 9:12 am
HI,
USE THIS QUERY,,
select *
from
Table_A join Table_B on convert(datetime,convert(varchar(10),Date_A,121)) = Date_B
REGARDS
AMIT
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy