Your code is completely insane, I'll therefore skip the suggestions.
This should be what you want
PHP Code:
SELECT DATE_FORMAT(CURRENT_DATE(), '%Y%d%m') currentDate
If you just want the current day of the month, this should do
PHP Code:
SELECT DAY(CURRENT_DATE()) AS currentDay
I just want to remind you that you don't really have to use your database to get the current day.
This is one way to get the current day in sourcepawn
PHP Code:
decl String:sTime[3];
FormatTime(sTime, sizeof(sTime), "%d");
new currentDay = StringToInt(sTime);
__________________