SA-MP Forums Archive
[ASK] How to get date yesterday if today is date 1 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [ASK] How to get date yesterday if today is date 1 (/showthread.php?tid=621402)



[ASK] How to get date yesterday if today is date 1 - Jonggol - 10.11.2016

Hi i'm confused how to get date 1 - 6 days before, if now is sunday but i will get data from mysql database, how to get date for 1-6 days before.

And also, 1 month not always 31 days, if sunday is date 1. and month before is 31/30/29/28 how to get date before. i'm confused because i will trying to make profit system for business. in my opinion i will make a table with fill (businessid (int), value(int), date(varchar)), if player buy item from business it work like /buy > Player buying item > Insert data on table within businessid, value, date (now). but i confused how to get data from mysql database?, and how to get date before sunday.

example image from jogjagamers rp
Image

Thanks before.


Re: [ASK] How to get date yesterday if today is date 1 - SickAttack - 10.11.2016

Create a function that gives you the days of a month on X year (take in note leap years). Then do your calculations from there and out.


Re: [ASK] How to get date yesterday if today is date 1 - Vince - 10.11.2016

If it is a datetime column you can use date_sub(). If it's a Unix timestamp you must first convert it to datetime.


Re: [ASK] How to get date yesterday if today is date 1 - Jonggol - 11.11.2016

Can you help me by creating sample code?.