By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,873 Members | 1,040 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,873 IT Pros & Developers. It's quick & easy.

Date Question

P: n/a
Hi,

We have a form where the user selects a date from a calendar, the date
is in the format May 23, 2008.

The date in the datebase is in the format 05212008.

What we need to do is get the starting and ending date of the week for
the date selected in the form: May 23, 2008, and then get the records
from the database where the dates fall within that range.

So, from that date / format: May 23, 2008, how can I find the
starting and ending dates for the week the date falls in???

I'm still searching.......

Thanks!

John
Jun 2 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 28 May 2008 01:11:57 +0200, Mtek <mt**@mtekusa.comwrote:
We have a form where the user selects a date from a calendar, the date
is in the format May 23, 2008.

The date in the datebase is in the format 05212008.

What we need to do is get the starting and ending date of the week for
the date selected in the form: May 23, 2008, and then get the records
from the database where the dates fall within that range.

So, from that date / format: May 23, 2008, how can I find the
starting and ending dates for the week the date falls in???
Use the date/time funcions available to you in your database (assuming you
had the common sense to store that value as a date, which all major
databases understand nowadays....). Ask in a group dedicated to your
choice of database how they'd solve it. Most likely a simple 'WHERE
WEEK(date) = WEEK(your data)' will get you all you want.

Failing that, your options are either using strtotime() to get relative
dates, or basic unix timestamps (worst case scenario: created with sub
strings) and some easy math. I strongly suggest to let a database
(probably highly optimised for this kind of thing) handle it.
--
Rik Wasmus
....spamrun finished
Jun 2 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.