[Solved] Query dates by month
-
- Posts: 3
- Joined: Mon Jun 25, 2012 11:44 pm
[Solved] Query dates by month
I'm fairly new to Base and ran into a wall.
I have a database "Customers" containing over 600 entries, with first names, last names, addresses (#, street, zip), birth dates and sites visited. I want to make a query that will list my customers by month of birth, so I can send them a birthday card. My DOB field is of DATE type and looks like MM/DD/YY.
I tried using the query wizard and I cannot figure out the criteria I should using. Nothing works and I'm stalled.
Please, help, and try to keep it simple for me. I know nothing of mySQL and Basic.
Thank you.
I have a database "Customers" containing over 600 entries, with first names, last names, addresses (#, street, zip), birth dates and sites visited. I want to make a query that will list my customers by month of birth, so I can send them a birthday card. My DOB field is of DATE type and looks like MM/DD/YY.
I tried using the query wizard and I cannot figure out the criteria I should using. Nothing works and I'm stalled.
Please, help, and try to keep it simple for me. I know nothing of mySQL and Basic.
Thank you.
Last edited by younghammer on Tue Jun 26, 2012 8:01 pm, edited 1 time in total.
OpenOffice 3.3.0 Windows 7
Re: Query dates by month
Are you using a MySQL database? Or does Base say "Embedded database" in the status bar at the bottom of your main Base window? Or perhaps something else?younghammer wrote:...I know nothing of mySQL and Basic.
Perhaps see:
https://www.google.com/search?sugexp=ch ... uery+month
Basic (language), on the other hand, is not necessary to solve this issue.
AOO 4.1.x; LO 4.2.x; Windows 7/8 64-bit
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
Warning: Avoid embedded databases --> Solution: Adopt a portable 'split database' folder
Soli Deo gloria
-
- Posts: 3
- Joined: Mon Jun 25, 2012 11:44 pm
Re: Query dates by month
Select all columns (*) plus a calculated month column:
Code: Select all
SELECT *, MONTH("Birth Date") AS "Month"
FROM "Your Table"
ORDER BY "Month"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Query dates by month
Just to add on to the sound advise given by Villeroy above, assuming you want to only see the records from your table ( "Customers" ), and, you want want to be prompted to input a given month number ( 1 to 12 ) to bring back all the records where "DOB" is that month, follow these steps:
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
- Open your OpenOffice Base file ( *.odb )
- On the left, click on the Queries icon
- Under Tasks, click on: Create Query in SQL View...
- Copy and paste the following SQL
Code: Select all
SELECT TO_CHAR( "DOB", 'MM/DD' ) AS "Birthday Date", "Customers".* FROM "Customers" AS "Customers" WHERE MONTH( "DOB" ) = :Enter_Month_Number_1_to_12 ORDER BY "Birthday Date" ASC, "Customers"."DOB" ASC
- Run your Query, EITHER:
- F5 key
- Run Query icon on Toolbar
- From the Menu: Edit -> Run Query
- When you are prompted, enter the month number . . . a number . . . from 1 to 12
- Save the Query so you can run it again / later
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
-
- Posts: 3
- Joined: Mon Jun 25, 2012 11:44 pm
Re: [Solved] Query dates by month
Sliderule:
It works perfectly! I appreciate how you kept your explanations simple and easy to follow. Now I can go forward with my birthday card idea.
Thank you!
It works perfectly! I appreciate how you kept your explanations simple and easy to follow. Now I can go forward with my birthday card idea.
Thank you!
OpenOffice 3.3.0 Windows 7
-
- Posts: 1
- Joined: Sat Nov 24, 2012 11:32 pm
Re: [Solved] Query dates by month
I have seen a lot of really good information and solutions, but some of it is not working for me. I’m not sure what I am doing wrong. I have a list of data on properties in my area. I am able to create a pivot table with the data that I need. However, I am trying to group the data by month. The original dataset has the date formatted as “date” - mm/dd/yyyy.
However, when I click on the first date in the pivot table and click “Data” -> “Group and Outline” -> “Group", it creates a copy of the date field instead of displaying a popup.
Is there something that I have done wrong? Data file is attached. Thanks for you assistance.
However, when I click on the first date in the pivot table and click “Data” -> “Group and Outline” -> “Group", it creates a copy of the date field instead of displaying a popup.
Is there something that I have done wrong? Data file is attached. Thanks for you assistance.
- Attachments
-
- Clinton.ods
- Data File
- (29.35 KiB) Downloaded 548 times
MAC 10.8.2 / OpenOffice 3.4.1
Re: [Solved] Query dates by month
gr8fulbishop:
Just as an FYI ( For Your Information ) . . . your question here is really a Calc ( Data Pilot ) question, rather than a Base question, so, I would suggest if you have additional questions about Data Pilot, ask in the Calc forum.
To answer your question, I have attached below, a copy of your Calc file, using Data Pilot, and, having it GROUP by month. Below, I described what I did.
Sliderule
Just as an FYI ( For Your Information ) . . . your question here is really a Calc ( Data Pilot ) question, rather than a Base question, so, I would suggest if you have additional questions about Data Pilot, ask in the Calc forum.
To answer your question, I have attached below, a copy of your Calc file, using Data Pilot, and, having it GROUP by month. Below, I described what I did.
- I opened your Calc file.
- In Sheet1, I changed ( altered ) the Close Date column, that is, I 'converted' the TEXT values to Date values ( I removed the beginning single quote ( ' ) so the result was a real date ( stored in the spreadsheet as an integer ).
- In your Data Pilot, in sheet: Pivot Table_Sheet1_1 , click on one of the dates, for example, 08/27/12
- Press F12, OR, From the Menu: Data -> Group and Outline -> Group...
- In the Grouping popup, in the Group By section, click the radio button for Intervals, and, choose, Months
- Click on the OK button
- Smile and say: "Gee Sliderule, that was easy. Now all I have to do is let the forum know I am able to Group my Calc output by Month, using DataPilot."
Sliderule
Re: [Solved] Query dates by month
@qwerty
Had to copy/paste yr spreadsheet and give correct format to each field.
I joined for you subsequent test file with your data listed in the report to suit your needs. Pls look at it.
Regards
Had to copy/paste yr spreadsheet and give correct format to each field.
I joined for you subsequent test file with your data listed in the report to suit your needs. Pls look at it.
Regards
- Attachments
-
- Test Rev 1.odb
- (14.8 KiB) Downloaded 322 times
Libre Office 6.0.7 on Ubuntu 18.04
Re: [Solved] Query dates by month
Did you intend to post this in viewtopic.php?t=110671 ?
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.