Nabi Gudiño
Nabi Gudiño

Reputation: 33

Timestamp to datetime in SQL (PHPmyAdmin)

I have a problem.

I have a table with BigInt dates. That BigInt are for example 20160614041115 (Date: 2016/06/14 04:11:15)

In other table I have DateTime dates.

I need to compare that dates...

I try from_unixtime(mytimestamp) but mytimestamp isn't a Unix Timestamp. Also try STR_TO_DATE(mytimestamp,'%Y%m%d%h%i%s'), and also STR_TO_DATE(CAST (mytimestamp AS VARCHAR),'%Y%m%d%h%i%s')...

Nothing work... Any ideas?? :(

Thanks in advance

Upvotes: 2

Views: 1347

Answers (1)

Nabi Gudiño
Nabi Gudiño

Reputation: 33

The way I solved it is Ryan Vincent's solutions. Like I said before, my timestamp is not a Unix Timestamp so I could'n use from_unixtime() function.

So, for anyone who need the answer, I finally use STR_TO_DATE + CAST...

STR_TO_DATE(CAST(mytimestamp AS CHAR), '%Y%m%d%h%i%s')

And go from this: 20160613005300

To this: 2016-06-13 00:53:00

Thanks for your answers!!!

Upvotes: 1

Related Questions