473,761 Members | 9,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Query - STANDARD DATE to YEAR-MONTH and WEEK

Hi,
A week ago I had a question how to get MS Query to return a standard
date to a "YEAR-MONTH" (YYYY-MM) format.

I received a great answer from Jerry Boone!!!

It follows:
SELECT convert(varchar (4),year(INVENT TRANS.DATEFINAN CIAL)) + '-' +
convert(varchar (2),month(INVEN TTRANS.DATEFINA NCIAL)) AS 'dfDate'

This workt great!!! Jerry, you rock! Thanks a million! If you lived in
Sweden I would have sent you a bottle of wine!

Maybe someone els, of Jerry, could help me to percect my report. I would
like to get MS Query to return the same date in "weeks". 2003-01-01
would be week 1.

I don´t want to have to do this in Excell. I´m pulling the date directly
into a pivottable. And would like the whole report to be self updatable.

Is this possible?

Best regards
/Papegoja

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
2 8628
"Papegoja" <an*******@devd ex.com> wrote in message
news:3f******** *************@n ews.frii.net...
Hi,
A week ago I had a question how to get MS Query to return a standard
date to a "YEAR-MONTH" (YYYY-MM) format.

I received a great answer from Jerry Boone!!!

It follows:
SELECT convert(varchar (4),year(INVENT TRANS.DATEFINAN CIAL)) + '-' +
convert(varchar (2),month(INVEN TTRANS.DATEFINA NCIAL)) AS 'dfDate'

This workt great!!! Jerry, you rock! Thanks a million! If you lived in
Sweden I would have sent you a bottle of wine!

Maybe someone els, of Jerry, could help me to percect my report. I would
like to get MS Query to return the same date in "weeks". 2003-01-01
would be week 1.

I don´t want to have to do this in Excell. I´m pulling the date directly
into a pivottable. And would like the whole report to be self updatable.

Is this possible?

Best regards
/Papegoja

We had a question on week numbers recently. You need to make sure what
standard you are working to. If you are working to the ISO 8601 standard,
then Week No 1 contains the fourth day of January - this means:
Jan 1, 2003 is in week 1 of 2003
Jan 1, 2005 is in week 53 of 2004

Or do you have another standard?

Fletcher
Nov 12 '05 #2
SELECT 'Week ' + datename(wk, INVENTTRANS.DAT EFINANCIAL)) AS 'dfWeek'
FROM INVENTTRANS
"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bn******** **@sparta.btint ernet.com...
"Papegoja" <an*******@devd ex.com> wrote in message
news:3f******** *************@n ews.frii.net...
Hi,
A week ago I had a question how to get MS Query to return a standard
date to a "YEAR-MONTH" (YYYY-MM) format.

I received a great answer from Jerry Boone!!!

It follows:
SELECT convert(varchar (4),year(INVENT TRANS.DATEFINAN CIAL)) + '-' +
convert(varchar (2),month(INVEN TTRANS.DATEFINA NCIAL)) AS 'dfDate'

This workt great!!! Jerry, you rock! Thanks a million! If you lived in
Sweden I would have sent you a bottle of wine!

Maybe someone els, of Jerry, could help me to percect my report. I would
like to get MS Query to return the same date in "weeks". 2003-01-01
would be week 1.

I don´t want to have to do this in Excell. I´m pulling the date directly
into a pivottable. And would like the whole report to be self updatable.

Is this possible?

Best regards
/Papegoja

We had a question on week numbers recently. You need to make sure what
standard you are working to. If you are working to the ISO 8601 standard,
then Week No 1 contains the fourth day of January - this means:
Jan 1, 2003 is in week 1 of 2003
Jan 1, 2005 is in week 53 of 2004

Or do you have another standard?

Fletcher

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
9295
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
11067
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
1314
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
3264
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
1518
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
7748
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
5587
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
3564
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
2233
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
6304
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
9554
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
10136
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9988
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...
1
9923
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8813
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
7358
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...
1
3911
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
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.