Avatar of mgmhicks
mgmhicks
 asked on

how to get time from datetime field and merge new date

I have a table with 2 fields.  A date field and a datetime field.    What I need to do is replace the date within the datetime field and keep the time.  The date of course would be the date in the other field.  Is there any what to do that within sql transactions.

thanks
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Jim Horn

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Horn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mgmhicks

ASKER
Thank  you Jim that seemed to work.  Here is what the code looks like had to do a *-1 to make it work, either way I set the fields.

UPDATE    transact
SET              CREATEDDATE = DATEADD(d, DATEDIFF(d, TRANSDATE, CREATEDDATE)* -1, CREATEDDATE)
WHERE     (TRANSDATE >= '04/07/2015')
Jim Horn

Sounds like a plan.  Thanks for the grade, good luck with your project.  -Jim
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck