0

I have a table where I have a long list of timestamps and there could be chances of timestamps missing for an entire day or days and I want to insert a single timestamp for that particular day

For example if there is no timestamp for 2014-04-04 I want it to insert 2014-04-04 00:00:00 for that particular day.

Can this be done in mysql ?

1 Answer 1

1

Yes it can.

Add a trigger for after insert to the table. Make the trigger insert the current timestamp if none has been provided.

Or change the column to have a default value of CURRENT_TIMESTAMP.

Those don't resolve the problem of previous entries having no values, but it does fix the problem for the future. Filling in the rest should be a straightforward update: update mytable set its_timestamp = date(datefield) where its_timestamp is NULL.

Sign up to request clarification or add additional context in comments.

1 Comment

I want it to add a timetstamp for the missing date not the current timestamp

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.