Link to home
Start Free TrialLog in
Avatar of Madison_Hollister
Madison_Hollister

asked on

Format DATETIME field in a Select Statement from MS SQL 2005?

One of them any columns of information I need from a MSSQL database contain DATETIME, I'm pulling this off of a server that is not local and importing the results into a local MySQL Server. I have two problems. First of all, the MSSQL Server is in UTC time, and I am in Eastern time, I have included what I use to fix this problem, I need to know now how to convert the Fields from MSSQLs format, to MySQL's:
DateTime in MSSQL:
4/3/2009 2:43AM
DateTime in MySQL (what I need the output from MSSQL to look like):
2009-04-03 02:43:00

Help would be much appreciated
This is how I convert from UTC to Eastern time:
declare @utcoffset datetime;
set @utcoffset = cast(getutcdate() - getdate() as decimal(12,7));
Then when I select a datetime field I do:
select field - @utcoffset, fiel2, field3 from table.
 
thus I'm assuming I would need to do select convert(field) - @utcoffset, or select convert(field - @utcoffset).

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial