473,499 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Query - STANDARD DATE to YEAR-MONTH

4 New Member
I'm extracting some data on the hand of MS query, out of an SQL server and put it in a pivot table ...

I found a threat about this in this forum,
but I've got a problem with it ...
If I put this command :

convert(varchar(4);year(HARP_TOT.D_FACT_YM))+'-'+convert(varchar(2);month(HARP_TOT.D_FACT_YM))

The results are like this : 2005-11, 2005-12, 2005-1, 2005-2, ...
Next, I have to put the data in a pivot table
and the months are not in the right order ...
It would have to be displayed like this : 2005-01, 2005-02, ... , 2005-10, ...

Has somebody any suggestions ? :confused:
Aug 16 '06 #1
5 3643
kaval
4 New Member
nobody can help me ?
Aug 17 '06 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this code.

Format([HARP_TOT.D_FACT_YM],"yyyy-mm")

This will return a String Value in the specified format. It is the only way I know of to assert the trailing 0 in the Month.



I'm extracting some data on the hand of MS query, out of an SQL server and put it in a pivot table ...

I found a threat about this in this forum,
but I've got a problem with it ...
If I put this command :

convert(varchar(4);year(HARP_TOT.D_FACT_YM))+'-'+convert(varchar(2);month(HARP_TOT.D_FACT_YM))

The results are like this : 2005-11, 2005-12, 2005-1, 2005-2, ...
Next, I have to put the data in a pivot table
and the months are not in the right order ...
It would have to be displayed like this : 2005-01, 2005-02, ... , 2005-10, ...

Has somebody any suggestions ? :confused:
Aug 17 '06 #3
kaval
4 New Member
I thank you very much and will try further on monday ...
At first sight, MS Query doesn't allow me to use this expression,
but I think that I don't put the expression at the right place ...
Thank you very much for the help indeed !!
Aug 17 '06 #4
kaval
4 New Member
Today, I tried the suggestion I received.
I had another error message like :
"parameters are not allowed for this query"

Thank you anyway ... but if someone has any other suggestion,
it would be a pleasure for me to try it out ;)
Aug 21 '06 #5
comteck
179 New Member
Does the year have to be ahead of the month? Try changing it around.

convert(varchar(2);month(HARP_TOT.D_FACT_YM))+'-'+convert(varchar(4);year(HARP_TOT.D_FACT_YM))

comteck
Aug 24 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

14
9270
by: Bob | last post by:
Hi there, Need a little help with a certain query that's causing a lot of acid in my stomach... Have a table that stores sales measures for a given client. The sales measures are stored per...
3
11048
by: Scott Morford | last post by:
I am developing a weed management database for the preserve I work on. One of the queries I'm working on will allow the user to run a query and see which weed patches have NOT been treated in the...
0
1303
by: Scott Morford | last post by:
This is a followup to a question I posed last summer. http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&selm=3f451dd4%240%241095%247f8943f3%40newsreader.visi.com I'm developing a weed...
6
3246
by: PMBragg | last post by:
Thank you everyone that helped me with my DateSerial question. I really do appreciate it. Now my accountant has told I need to pull the inventory for just the year I'm depreciating. Is there a way...
3
1499
by: Matthew Kramer | last post by:
How would be the best way to do this in Access? I have two tables. The first table has all the rows of data. The first column of this table has a country name, the second has a year and the...
4
7730
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
5
5562
by: ????? | last post by:
I have an access query which gets data from a number of different tables. Although the tables have primary key fields, the order in which the records are returned means that none of these are in...
2
3548
by: Bernd Hohmann | last post by:
Dear collegues, small query problem. A table (simplified example)... customer as char(5) inv_date as date amount as double
2
2214
by: Jimmy Stewart | last post by:
Ok, I'm trying to write a query that is starting to wear me down. What I'm trying to do is create a year end report that gets sent to all of my customers who meet two criteria. One they are...
6
6279
craigfr
by: craigfr | last post by:
I am making a graph comparing last year's defect data with YTD defect data. Our fiscal year starts Nov.1 and ends Oct.31. To get the YTD, I started used a simple date serial criteria: Between...
0
7007
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...
0
7174
Oralloy
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,...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.