Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 03:33 PM
Papegoja
Guest
 
Posts: n/a
Default 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(INVENTTRANS.DATEFINANCIAL) ) + '-' +
convert(varchar(2),month(INVENTTRANS.DATEFINANCIAL )) 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!
  #2  
Old November 12th, 2005, 03:33 PM
Fletcher Arnold
Guest
 
Posts: n/a
Default Re: MS Query - STANDARD DATE to YEAR-MONTH and WEEK

"Papegoja" <anonymous@devdex.com> wrote in message
news:3f94fa92$0$197$75868355@news.frii.net...[color=blue]
> 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(INVENTTRANS.DATEFINANCIAL) ) + '-' +
> convert(varchar(2),month(INVENTTRANS.DATEFINANCIAL )) 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[/color]


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


  #3  
Old November 12th, 2005, 03:41 PM
Jerry Boone
Guest
 
Posts: n/a
Default Re: MS Query - STANDARD DATE to YEAR-MONTH and WEEK

SELECT 'Week ' + datename(wk, INVENTTRANS.DATEFINANCIAL)) AS 'dfWeek'
FROM INVENTTRANS


"Fletcher Arnold" <fletch@home.com> wrote in message
news:bn2uv8$ers$1@sparta.btinternet.com...[color=blue]
> "Papegoja" <anonymous@devdex.com> wrote in message
> news:3f94fa92$0$197$75868355@news.frii.net...[color=green]
> > 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(INVENTTRANS.DATEFINANCIAL) ) + '-' +
> > convert(varchar(2),month(INVENTTRANS.DATEFINANCIAL )) 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[/color]
>
>
> 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
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,164 network members.