Day/Month.
#1

How do I get the day/month that we're currently in? (In real life)
Reply
#2

getdate(). You can't find out the day of the week (Monday, Tuesday, etc) though. At least you can't without some sophisticated coding. A mysql server can calculate the day of the week, as well as the CTime library (read that somewhere).
Reply
#3

I use MySQL, but I really don't understand how to get the day and month.

I just read up about the GetDate function, I could possible try make a stock for the month thing, but the day thing, maybe difficult.

Although, I could start on today, EG:

if(day == 30) format(string, sizeof(string), "Wednesday");

Could that work? Thanks!
Reply
#4

Aye. Thanks ******.
Reply
#5

Fortunately, I found this after searching:

pawn Код:
// Credit to yom
stock GetWeekDay(day=0, month=0, year=0) {
    if(!day)
        getdate(year, month, day);

    new
        szWeekDay[10],
        j,
        e;

    if(month <= 2) {
        month += 12;
        --year;
    }
   
    j = year % 100;
    e = year / 100;

    switch((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7) {
        case 0: szWeekDay = "Saturday";
        case 1: szWeekDay = " Sunday";
        case 2: szWeekDay = " Monday";
        case 3: szWeekDay = " Tuesday";
        case 4: szWeekDay = "Wednesday";
        case 5: szWeekDay = "Thursday";
        case 6: szWeekDay = " Friday";
    }

    return szWeekDay;
}
It seemed to work when I tested (though the test script will return the day for 2 days ago as I subtracted 2 from the day count after getdate()) it.
Reply
#6

Thank you Calgon!

Are you on MSN matey?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)