Click to See Complete Forum and Search --> : where date is within last day, week, month, etc.


ripken204
02-01-2008, 04:24 PM
i have the ability to search for entires whose dates are from today, this week, this month, 3 months, 6 months, one year

the date is stored as a datetime. how exactly would i make this condition statement?

jasonahoule
02-01-2008, 04:56 PM
What DBMS are you using?

ripken204
02-01-2008, 04:59 PM
php+mysql

jasonahoule
02-01-2008, 05:09 PM
you can say

WHERE date BETWEEN $date AND NOW()

I think NOW() is a MySQL function. Too many databases.

ripken204
02-01-2008, 05:12 PM
ya right now i have the current week and current month working by using date_format, pulling the day and/or week and/or month and comparing it to NOW

those are pretty much exact things ^^

so now all i need to do is figure out how to get a date from 3 and 6 months ago, like 3month_date=NOW()-3months
i have no idea how to do this

edit: ooh
ex from internet: DATE_SUB(CURDATE(),INTERVAL 30 DAY)

mathurdeepesh
02-05-2008, 03:39 AM
ya right now i have the current week and current month working by using date_format, pulling the day and/or week and/or month and comparing it to NOW

those are pretty much exact things ^^

so now all i need to do is figure out how to get a date from 3 and 6 months ago, like 3month_date=NOW()-3months
i have no idea how to do this

edit: ooh
ex from internet: DATE_SUB(CURDATE(),INTERVAL 30 DAY)
Hi,
In below query
when i execute this TRANS_DATE field returns DATE in MM/dd/yyyy
i want out put in MM/dd/yyyy hh:mi:ss format
so plz tell me what change i have to do?


select th.TRANS_NO,th.TRANS_DATE
from TRANS_HEADER th,TRANS_DETAIL td
where th.TRANS_NO=td.TRANS_NO
and th.TRANS_TYPE='O'
and th.LOC_FROM=21300
and th.LOC_TO=21100

mathurdeepesh
02-05-2008, 03:40 AM
i have the ability to search for entires whose dates are from today, this week, this month, 3 months, 6 months, one year

the date is stored as a datetime. how exactly would i make this condition statement?
Hi,
In below query
when i execute this TRANS_DATE field returns DATE in MM/dd/yyyy
i want out put in MM/dd/yyyy hh:mi:ss format
so plz tell me what change i have to do?


select th.TRANS_NO,th.TRANS_DATE
from TRANS_HEADER th,TRANS_DETAIL td
where th.TRANS_NO=td.TRANS_NO
and th.TRANS_TYPE='O'
and th.LOC_FROM=21300
and th.LOC_TO=21100

chazzy
02-05-2008, 06:35 AM
Hi. Feel free to start your own thread w/ your own issue - no need to bump other threads especially since your problem isn't related at all. But anyways, depending your database, there should be a function like DATE_FORMAT to format your date. What database do you use?

jasonahoule
02-05-2008, 07:27 AM
And what type is the field.