0

Table have one column which contain timestamp value.I want to convert that timestamp value to date&time in SQL.

When I using like this

select cast(1520339311 as datetime)  

I'm getting an error:

Arithmetic overflow error converting expression to data type datetime

How to handle that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
pinky
  • 193
  • 2
  • 3
  • 12
  • 1
    Possible duplicate of [Arithmetic overflow error converting expression to data type datetime. (while displaying date time..)](https://stackoverflow.com/questions/18416623/arithmetic-overflow-error-converting-expression-to-data-type-datetime-while-di) – rochy_01 Mar 13 '18 at 09:23
  • https://stackoverflow.com/questions/8119386/how-to-convert-sql-servers-timestamp-column-to-datetime-format – WhatsThePoint Mar 13 '18 at 09:23
  • 1
    Which [DBMS](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product. Please add a tag for the database product you are using `postgresql`, `oracle`, `sql-server`, `db2`, ... –  Mar 13 '18 at 09:25
  • 1
    `1520339311` is not a timestamp, that's an integer. A timestamp is `2018-03-13 10:26:00` –  Mar 13 '18 at 09:26
  • Ok.Can u pls give me solution to convert it – pinky Mar 13 '18 at 09:35

1 Answers1

1

SQL Server's TIMESTAMP datatype has nothing to do with a date and time! See the links Below:

CAST and CONVERT (Transact-SQL)

rowversion (Transact-SQL)

Already Answered