Welcome Guest, Not a member yet? Register   Sign In
How to get first day of previous month
#1

[eluser]zeedy2k[/eluser]
What im trying to do is list fields where last update was after 1st day of the previous month

EG
We are currently on 28 July so would need it to calculate which updates occurred AFTER 1st June.

Is there an easy way of doing this?

Cheers
Robert
#2

[eluser]Krzemo[/eluser]
Is it database query related question?
#3

[eluser]zeedy2k[/eluser]
Yeah... Basically the field in the database of the last ad is 'lastad' and it is the current timestamp using time() that the record was created.
#4

[eluser]n0xie[/eluser]
Calculate the timestamp of the 1st of the previous month and use a WHERE clause in your query?
#5

[eluser]zeedy2k[/eluser]
Yeah thats not a problem... but whats the easiest way to calculate the 1st of the previous month?
#6

[eluser]Krzemo[/eluser]
From top of my head...
Code:
SELECT DATE_ADD(LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 2 MONTH)), INTERVAL 1 DAY)




Theme © iAndrew 2016 - Forum software by © MyBB