tanj1035
asked on
SQL, how to cast the timestamp to the same format
Hi Experts,
In table A, the column " created on" has value "2015-06-02 10:27:11.787"
In table B, the column " submittedtimestamp" has value "2015-06-02 10:27:11.780"
I want to make those 2 columns to the same format, which means 2015-06-02 10:27=2015-06-02 10:27
select *
from A a inner join B b on a. createdon = b. submittedtimestamp
Can you help me on the query.
Thanks,
In table A, the column " created on" has value "2015-06-02 10:27:11.787"
In table B, the column " submittedtimestamp" has value "2015-06-02 10:27:11.780"
I want to make those 2 columns to the same format, which means 2015-06-02 10:27=2015-06-02 10:27
select *
from A a inner join B b on a. createdon = b. submittedtimestamp
Can you help me on the query.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the hint, Scott.
select *
from A a
inner join B b on b. submittedtimestamp >= dateadd(minute, datediff(minute, 0, a.createdon), 0) and b. submittedtimestamp < dateadd(minute, datediff(minute, 0, a.createdon) + 1, 0)