how can i convert a field contain data 733803 as into be datetime on sql server?
A:
You can simply cast from integer to datetime like so:
declare @outDate as datetime
set @outDate = CAST(@integerValue as datetime)
Of course, that presumes that your integers are valid sql integer representations of datetimes and will probably also depend upon regional settings of the servers you are running this on.
For example, the integer you provided converts to a date in 3909 on my sql server, so perhaps there is something else going on in the generation of that int?
David Hall
2010-04-22 02:24:05
so sad it's not from sql server int representations of datetime.front end application using magic 7 for windows and sql server 2000 as database.
Irman
2010-04-29 02:12:29
+1
A:
What data is 733803? Is it a unix timestamp? If it is the answer is below.
select dateadd(ss, 733803, '1970-01-01')
Alex Park
2010-04-22 02:27:45
user input date using magic 7 for windows application into sql server 2000
Irman
2010-04-29 02:09:28
Is it seconds or some patterns or something?What is the correct conversion? (733803 -> ?)
Alex Park
2010-04-30 01:07:17
select dateadd(ss, 733803, '1970-01-01') this one results 1970-01-09 11:50:03.00 expected to be 2010-01-01 00:00:00
Irman
2010-04-30 02:10:28