473,624 Members | 2,232 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_T OT.D_FACT_YM))+ '-'+convert(varch ar(2);month(HAR P_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 3650
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_T OT.D_FACT_YM))+ '-'+convert(varch ar(2);month(HAR P_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(varch ar(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
9286
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 year and there could be multiple sales measures every year per client. There is another field called last update date. If there are multiple sales measures then need to select the one that's been entered last based on this field. Also, if there
3
11059
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 current calendar year. This query involves two tables. The first contains the static information about the weed patches. The second contains Treatment information. The tables look something like this Static Table fields: Weed_ID (integer)
0
1310
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 management database to track our weed management practices in the eventual hope of using some statistical models on the data to measure outcome\success. The database contains principally two tables. One table contains static information such as an...
6
3256
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 to isolate by my field, to get the Year I need? Michael
3
1511
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 third column is the data value. The second table is just a list of standard years ie. 1980, 1985, 1990, 1995). Is there a way to arrange a query so that all of the rows in table 1
4
7741
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, but I can't update record in query or in form. I believe the problem is due to the source query. In source query, there is a filter to show the incomplete record ("is null" in delivery date)], but I need to re-use the job no. if the job is...
5
5578
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 ascending order in the query result set. I need to include in the query a field that numbers the records in the order that they are returned. The numbers must be unique and ascending but do not necessarily have to be consecutive. For Example:
2
3557
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
2225
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 'Residential' customer AND they have had business with us during this past year. My report is based on a query. The query has two tables associated with it. One is tblClients which provides client name, account type and the other relevant mailing...
6
6295
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 DateSerial(Year(Date())-1,11,1) And Date() This works, but only for 10 months out of the year. If your'e in December, it will calculate the YTD from last year's November to the current December, not the last November. My solution was to make an...
0
8242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8629
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8488
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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 we have to send another system
2
1488
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.