Jump to content

MYSQL Query Question


tomtimms

Recommended Posts

I've been trying to wrap my brain from this and can't figure it out.  I have data that at the begging of the month the sum of the data goes into a table.  So all data for April get's summed up on may 1st and then stored into a table with the date format 2010-04.  I need a query that will display the results 45 days later, so on May 15th the 2010-04 data will be shown.  I hope this makes some sense, I can't seem to figure it out.

Link to comment
https://forums.phpfreaks.com/topic/200719-mysql-query-question/
Share on other sites

yes its a VARCHAR (64) as I needed it to be custom time field.  The data stored in APRIL is financial and payments go out 45 days after the month is over.  So on May 1st I need the data to show up that payment is due on may 15th.  I hope that explains a little better.  I will eventually need to have 30 days and 15 days as well, but for now just 45.

I don't see why you don't just change the column type to datetime and instead of storing 2010-04 just store 2010-04-01 00:00:00.

 

VARCHAR(64) is 57 more bytes more than you need.  datetime is usually 8 or 9 bytes which is 1 or 2 more than you need, but it allows you to use the datetime functions which make calculating date differences very easy.

 

Alternatively you could CONCAT '-01' to your column value and CAST that to datetime and still use the datetime functions.

 

But VARCHAR(64) is a bad design decision.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.