0

This is getting NULL, why?

select unix_timestamp(addtime(date(now()), time(from_unixtime(1426705199))))

For some reason, it is running correctly, however it only outputs NULL

2 Answers 2

1

I often find, when confronted with an error, that the manual can be a useful resource:

ADDTIME() adds expr2 to expr1 and returns the result. expr1 is a time or datetime expression, and expr2 is a time expression.

You are using a date value for expr1. Try casting it back to datetime expression:

select unix_timestamp(addtime(
   timestamp(date(now()))
   , time(from_unixtime(1426705199))))
Sign up to request clarification or add additional context in comments.

Comments

0

This should work?

 SELECT UNIX_TIMESTAMP(NOW())

If you want to get it from your own field then use this..

SELECT UNIX_TIMESTAMP(yourField);

1 Comment

I want to generate hour:min from other field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.