[ASK] How to get date yesterday if today is date 1
#1

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.
Reply
#2

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.
Reply
#3

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

Can you help me by creating sample code?.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)