/    Sign up×
Community /Pin to ProfileBookmark

How to determine start of week?

I have date field and would like to define that server detects start of week. How to do it automatic? Need help :rolleyes:

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@bokehNov 17.2005 — Well first you need to define what you consider to be the start of the week. What do you mean a date field? Do you mean in MySQL?
Copy linkTweet thisAlerts:
@toplisekauthorNov 17.2005 — I have field Date in table in Db on server. I would like that it will be recognised [B]EACH[/B] date which is the start of week. Yes I have MySQL db
Copy linkTweet thisAlerts:
@bokehNov 17.2005 — the start of week[/QUOTE]What do you consider is the start of the week?
Copy linkTweet thisAlerts:
@toplisekauthorNov 17.2005 — Each year there are different days which are start of week. So, I was thinking to have field week and within dates which will be start of weeks for every year. Is this good approach?

Start of week would be Monday ?
Copy linkTweet thisAlerts:
@chazzyNov 17.2005 — Hey.

Try this query out

"SELECT * FROM YOUR_TABLE WHERE DATE_FORMAT(YOUR_DATE_COLUMN,'%W') = 'Monday'"

That should get you the records for every Monday.

You can also use DATE_FORMAT(YOUR_DATE_COLUMN,'%w') = 1; See also

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
Copy linkTweet thisAlerts:
@toplisekauthorNov 17.2005 — Thanks, I will do
×

Success!

Help @toplisek spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...