Date coding issue

时间:2015-10-06 08:58:04

标签: mysql sql sql-server date datetime

In my company front end system shows the "proper" date but when i am querying the database from embarcaderoRapid SQL it shows me date as a below (database) .

Its a problem for me as in our front end view we are not able to group results etc and i can do it in embarcadero.

But i need to understand what is the logic behind this date "transformation" ?

Any thoughts ?

Ofcourse i could mapp it as i figured out whats everymonth code but without understanding i will have to to this for every new month.

front end           database
01/04/2015 00:000   1427842800000
01/04/2015 00:000   1427842800000
01/05/2015 00:000   1430434800000
01/05/2015 00:000   1430434800000
01/05/2015 00:000   1430434800000
01/06/2015 00:000   1433113200000
01/06/2015 00:000   1433113200000
01/07/2015 00:000   1435705200000
01/07/2015 00:000   1435705200000
01/08/2015 00:000   1438383600000
01/08/2015 00:000   1438383600000

EDIT:

Thank You for You response. You are near the answer.

Is there any function or a method in SQL/EXCEL to convert this timestamp to date we usually see ?

I also checked 04/01/2015 @ 12:00am (UTC) == 1427846400. and got same results. No sure why this is happening as my database shows 1427842800000

3 个答案:

答案 0 :(得分:2)

I'm not sure I understand your question.

In the database you have a date stored as a timestamp, i.e. the number of seconds since 1/1/1970. In your frontend, the date is displayed as we usually see a date.

See: http://www.unixtimestamp.com/, when i'm writing this answer the date is 1444122272.

EDIT : by the way, your frontend date must be in a specific timezone because 04/01/2015 @ 12:00am (UTC) == 1427846400.

答案 1 :(得分:0)

DECLARE @TS bigint
Set @TS ='1427842800000'
SELECT DATEADD(MINUTE,60,DATEADD(MILLISECOND, @TS % 1000, DATEADD(SECOND, @TS / 1000, '19700101')))

修改:考虑时区

答案 2 :(得分:0)

尝试 from-unixtime()功能。官方链接为here