Hi, my table has to have a column with the months names (january,
february...).
When I order it by month it is ordered alphabetically and that's not
what I need.
Reading this ng I found someone suggesting to replace names with
numbers (datatype: number) so jan is 1, feb is 2 and so on...and then
to ma ke a query using the format command.
I wrote an example:
SELECT Format([Name],"mmmm") AS NameMonths
FROM Subscriptions
ORDER BY Format([Name],"mmmm");
I made the table and I wrote 3,2,1 as an example...and when I run the
query it writes December, January, January.
So, wrong months names...what's wrong?
Is it the right way to manage and solve my problem with ordering by
month?
Thank you,
Ataru Morooka 5 8571
Ataru Morooka wrote: Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone suggesting to replace names with numbers (datatype: number) so jan is 1, feb is 2 and so on...and then to ma ke a query using the format command.
I wrote an example: SELECT Format([Name],"mmmm") AS NameMonths FROM Subscriptions ORDER BY Format([Name],"mmmm");
I made the table and I wrote 3,2,1 as an example...and when I run the query it writes December, January, January. So, wrong months names...what's wrong? Is it the right way to manage and solve my problem with ordering by month? Thank you, Ataru Morooka
The "mmmm" format is designed for date datatypes, not numbers.
Your solution would have worked if your [name] column had a date
datatype, and instead of values 3,2,1 you had entered (say)
25 mar 2004, 17 feb 2004, 10 jan 2004.
Since your [name] column has a number datatype, you'll need to
use a different function to convert numbers to month names for
display. A simple possibility is the Choose function (you'll find
more details in Access' help for that function):
SELECT Choose([name],"January","February","March","April","May",
"June","July","August","September","October","Nove mber","December")
AS NameMonths
FROM Subscriptions
ORDER BY [name];
The above assumes that all your users will be using English.
Here's an alternative that takes account of the user's language
preference by first converting [name] to a date (the 1st of
[name] 1901), then applying the "mmmm" format:
SELECT Format(DateSerial(1,[name],1),"mmmm") AS NameMonths
FROM Subscriptions
ORDER BY [name];
There are probably loads of other ways - these are just a start.
Cheers
Helen, you are splendid...your help was needed.
The db will be in italian, so I'll just translate those names in italian.
Have a great day,
Ataru
Helen Wheels <he**********@yahoo.com.au> wrote in message news:<41**************@yahoo.com.au>... Ataru Morooka wrote: Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone suggesting to replace names with numbers (datatype: number) so jan is 1, feb is 2 and so on...and then to ma ke a query using the format command.
I wrote an example: SELECT Format([Name],"mmmm") AS NameMonths FROM Subscriptions ORDER BY Format([Name],"mmmm");
I made the table and I wrote 3,2,1 as an example...and when I run the query it writes December, January, January. So, wrong months names...what's wrong? Is it the right way to manage and solve my problem with ordering by month? Thank you, Ataru Morooka
The "mmmm" format is designed for date datatypes, not numbers. Your solution would have worked if your [name] column had a date datatype, and instead of values 3,2,1 you had entered (say) 25 mar 2004, 17 feb 2004, 10 jan 2004.
Since your [name] column has a number datatype, you'll need to use a different function to convert numbers to month names for display. A simple possibility is the Choose function (you'll find more details in Access' help for that function):
SELECT Choose([name],"January","February","March","April","May", "June","July","August","September","October","Nove mber","December") AS NameMonths FROM Subscriptions ORDER BY [name];
The above assumes that all your users will be using English. Here's an alternative that takes account of the user's language preference by first converting [name] to a date (the 1st of [name] 1901), then applying the "mmmm" format:
SELECT Format(DateSerial(1,[name],1),"mmmm") AS NameMonths FROM Subscriptions ORDER BY [name];
There are probably loads of other ways - these are just a start.
Cheers
Aaargh, here I am again...maybe Helen or someone else culd help.
As suggested I used the CHOOSE command to repleace a list of numbers
with the months names and then I ordered those months correctly.
NOW the problem is that when I create a REPORT on that query, the
report correctly shows the months names but they are not ordered
correctly....and...if I order them they are again ordered
alphabetically!!!
Any help....again?
Thank you,
Ataru at**********@yahoo.com (Ataru Morooka) wrote in message news:<c9**************************@posting.google. com>... Helen, you are splendid...your help was needed. The db will be in italian, so I'll just translate those names in italian. Have a great day, Ataru
Helen Wheels <he**********@yahoo.com.au> wrote in message news:<41**************@yahoo.com.au>... Ataru Morooka wrote: Hi, my table has to have a column with the months names (january, february...). When I order it by month it is ordered alphabetically and that's not what I need. Reading this ng I found someone suggesting to replace names with numbers (datatype: number) so jan is 1, feb is 2 and so on...and then to ma ke a query using the format command.
I wrote an example: SELECT Format([Name],"mmmm") AS NameMonths FROM Subscriptions ORDER BY Format([Name],"mmmm");
I made the table and I wrote 3,2,1 as an example...and when I run the query it writes December, January, January. So, wrong months names...what's wrong? Is it the right way to manage and solve my problem with ordering by month? Thank you, Ataru Morooka
The "mmmm" format is designed for date datatypes, not numbers. Your solution would have worked if your [name] column had a date datatype, and instead of values 3,2,1 you had entered (say) 25 mar 2004, 17 feb 2004, 10 jan 2004.
Since your [name] column has a number datatype, you'll need to use a different function to convert numbers to month names for display. A simple possibility is the Choose function (you'll find more details in Access' help for that function):
SELECT Choose([name],"January","February","March","April","May", "June","July","August","September","October","Nove mber","December") AS NameMonths FROM Subscriptions ORDER BY [name];
The above assumes that all your users will be using English. Here's an alternative that takes account of the user's language preference by first converting [name] to a date (the 1st of [name] 1901), then applying the "mmmm" format:
SELECT Format(DateSerial(1,[name],1),"mmmm") AS NameMonths FROM Subscriptions ORDER BY [name];
There are probably loads of other ways - these are just a start.
Cheers
Ataru Morooka wrote: Aaargh, here I am again...maybe Helen or someone else culd help. As suggested I used the CHOOSE command to repleace a list of numbers with the months names and then I ordered those months correctly. NOW the problem is that when I create a REPORT on that query, the report correctly shows the months names but they are not ordered correctly....and...if I order them they are again ordered alphabetically!!! Any help....again? Thank you, Ataru
An Access report usually ignores any sorting used in the report's
recordsource, so although your query is sorted OK, a report based
on it won't necessarily be OK too. To make sure the report is
sorted the way you want, open the report in design view and
select View/Sorting and grouping from the menu. In the sorting
and grouping popup, choose the field you want the report to sort
by - in your case you'll need to choose the field containing the
month number, not the month name.
Hope that helps!
YES! In my original query I was having only the column with the months
names...I have added a column with the months numbers. Then I have
created the report and sorted it on the numbers (before I couldn't
because that column wasn't there, obviously!). On the page then I left
the months names and cancelled the numbers...and now it is perfect.
Really thank you,
Ataru
Helen Wheels <he**********@yahoo.com.au> wrote in message news:<41**************@yahoo.com.au>... Ataru Morooka wrote: Aaargh, here I am again...maybe Helen or someone else culd help. As suggested I used the CHOOSE command to repleace a list of numbers with the months names and then I ordered those months correctly. NOW the problem is that when I create a REPORT on that query, the report correctly shows the months names but they are not ordered correctly....and...if I order them they are again ordered alphabetically!!! Any help....again? Thank you, Ataru
An Access report usually ignores any sorting used in the report's recordsource, so although your query is sorted OK, a report based on it won't necessarily be OK too. To make sure the report is sorted the way you want, open the report in design view and select View/Sorting and grouping from the menu. In the sorting and grouping popup, choose the field you want the report to sort by - in your case you'll need to choose the field containing the month number, not the month name. Hope that helps! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Cherrish Vaidiyan |
last post by:
hello googles,
I have a small sqlplus problem. i have created a table with date field
along with other varchar2,number etc. But unfortunately i made a
mistake in entering the date. for some date...
|
by: Tom Petersen |
last post by:
I must have the format of the below line wrong for IE:
click <a href="cal.asp?sdate=<% =strDate1 %>&location=<% =strLocation
%>&eTime=<% =strDate2 %>">here</a> to add this information to your...
|
by: lsy |
last post by:
i wonder how can i order my statement interm of "ORDER BY FORMAT(Date, 'mmmm')" with using this it will order by alphabethical but i want it order by month... i had try "ORDER BY FORMAT(Date, 'mm')"...
|
by: Galina |
last post by:
Hello
All of a sudden I started getting error 13, type mismatch in a
command, which was running happily for years. Here is a code:
Option Compare Database
Option Explicit
Dim CmdClose1_Clicked...
|
by: Coleen |
last post by:
Hi all :-)
I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after...
I'm trying to get the date to go to the...
|
by: Piotr |
last post by:
Hi,
I have following problem:
I use a form in excel to send data into mysql server, everything is ok
unless I have to deal with decimals or data fields, this simple are not
recognized.
For...
|
by: shsandeep |
last post by:
I used the following query to retrieve the date in dd-mon-yyyy format.
db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' ||
RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
|
by: andreas |
last post by:
When I copy a vb.net project using date formats from one PC with a windows
date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I
get errors.
How can I change for a while in the...
|
by: Richiep |
last post by:
I am trying to get a UK format date of dd/mm/yyyy.
Why does the following subroutine not return a valid date in a web form?
The date returned is #12:00:00 AM# but the date I entered into the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |