• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Searching by Day

Explorer ,
Mar 12, 2007 Mar 12, 2007

Copy link to clipboard

Copied

I have a database full of kind of sales numbers. I want to be able to search for all the say, Fridays, or Tuesdays to see the numbers on those days specifically. I know how to do date ranges, but not specific days so it could pull up the last 27 Fridays that data was inputed on.

Thanks!!
TOPICS
Advanced techniques

Views

321

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2007 Mar 12, 2007

Copy link to clipboard

Copied

It largely depends on the database and the date functions available to it. Of course, you could always use cf to generate a list of the last 27 Fridays and use that list in your query.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

In MS SQL you can use:

WHERE DatePart(dw, myDateField) = 1

1 = Sunday
7 = Saturday

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

the database is mysql. that mssql line does not work with it and i can not find a datepart function on the mysql website.

anybody else here to help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 13, 2007 Mar 13, 2007

Copy link to clipboard

Copied

LATEST
A quick google search turned up the mySQL date_format () function:

WHERE date_format(myDateField, '%W') = 'Friday'

I'm not that familiar with mySQL databases myself, so you might have to play around with the syntax above, but it seems like it should fill your requirements.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation