Showing posts with label migrating. Show all posts
Showing posts with label migrating. Show all posts

Tuesday, February 14, 2012

DATE AND HOUR

Hello people,

I'm migrating an application from asp to asp.net and access to ms sql 2005. On the old db, there's a table with a column to store date and a column to store time. Ms sql only works with date and time together, right? I created a query to get the time from time column and update the date column inserting the time. I did something like this:

UPDATE S_ACC_MONEY
SET Date_Oper = CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108)

Does anyone knows a better way to do that? Any other comments?

Thanks!

you might also want to do a final conversion to datetime as in:

Date_Oper =CONVERT(datetime,CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108))