A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

aggregate function



 
 
Thread Tools Display Modes
  #1  
Old December 27th, 2005, 05:51 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

i import a table with this value as the timestamp (seen as a text data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.

  #2  
Old December 27th, 2005, 06:00 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

samuel wrote:
i import a table with this value as the timestamp (seen as a text
data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.


The Format function (when fed "mm" as the format argument) expects an Access
DateTime to be fed in as the input. The first 8 characters of your field is not
a DateTime, but rather a String. For your Format function to work you would
first have to convert that String into a DateTime.

Since "mm" only gives the number for the month anyway just use the Mid fiunction
to grab those characters...

=Mid([xact_dat_x], 5, 2)

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



  #3  
Old December 27th, 2005, 06:22 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

Rick Brandt wrote:

samuel wrote:

i import a table with this value as the timestamp (seen as a text
data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.



The Format function (when fed "mm" as the format argument) expects an Access
DateTime to be fed in as the input. The first 8 characters of your field is not
a DateTime, but rather a String. For your Format function to work you would
first have to convert that String into a DateTime.

Since "mm" only gives the number for the month anyway just use the Mid fiunction
to grab those characters...

=Mid([xact_dat_x], 5, 2)


.... which is what I would suggest, too, but if you want a month name you
could use something like

Format(Mid([xact_dat_x],5,2) & "/1/2005","mmmm")

For example:

[Table1] Table Datasheet View:
xact_dat_x
----------------
2005112602465800

[Q_Months] SQL:

SELECT Format(Mid([xact_dat_x],5,2) & "/1/2005","mm")
AS MonthNum,
Format(Mid([xact_dat_x],5,2) & "/1/2005","mmm")
AS MonthAbbr,
Format(Mid([xact_dat_x],5,2) & "/1/2005","mmmm")
AS MonthName
FROM Table1;

[Q_Months] Queary Datasheet View:

MonthNum MonthAbbr MonthName
-------- --------- ---------
11 Nov November


-- Vincent Johns
Please feel free to quote anything I say here.
  #4  
Old December 27th, 2005, 06:23 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

Access is not recognizing your data as a date.
If you want the month from it use –
Right(Left([xact_dat_x],6),2)


"samuel" wrote:

i import a table with this value as the timestamp (seen as a text data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.

  #5  
Old December 27th, 2005, 06:28 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

thanks for the help.

would it be possible to display Nov instead of 11 ?

"KARL DEWEY" wrote:

Access is not recognizing your data as a date.
If you want the month from it use –
Right(Left([xact_dat_x],6),2)


"samuel" wrote:

i import a table with this value as the timestamp (seen as a text data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.

  #6  
Old December 27th, 2005, 07:11 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

PERFECT!!

thanks so much...

"KARL DEWEY" wrote:

Format(DateSerial(Left([xact_dat_x],4),Right(Left([xact_dat_x],6),2),Right(Left([xact_dat_x],8),2)),"mmm")

Or this for full spelling
Format(DateSerial(Left([xact_dat_x],4),Right(Left([xact_dat_x],6),2),Right(Left([xact_dat_x],8),2)),"mmmm")

"samuel" wrote:

thanks for the help.

would it be possible to display Nov instead of 11 ?

"KARL DEWEY" wrote:

Access is not recognizing your data as a date.
If you want the month from it use –
Right(Left([xact_dat_x],6),2)


"samuel" wrote:

i import a table with this value as the timestamp (seen as a text data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.

  #7  
Old December 27th, 2005, 07:24 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

"Vincent Johns" wrote in message
om...

... which is what I would suggest, too, but if you want a month name you
could use something like

Format(Mid([xact_dat_x],5,2) & "/1/2005","mmmm")



Just a warning. That won't work for users who have their short date form set
(in Regional Setting) to dd/mm/yyyy: it'll return January in all cases.

Far safer is:

Format(DateSerial(2005, Mid([xact_dat_x],5,2) , 1), "mmmm")



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)




  #8  
Old December 27th, 2005, 08:55 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

Format(DateSerial(Left([xact_dat_x],4),Right(Left([xact_dat_x],6),2),Right(Left([xact_dat_x],8),2)),"mmm")

Or this for full spelling
Format(DateSerial(Left([xact_dat_x],4),Right(Left([xact_dat_x],6),2),Right(Left([xact_dat_x],8),2)),"mmmm")

"samuel" wrote:

thanks for the help.

would it be possible to display Nov instead of 11 ?

"KARL DEWEY" wrote:

Access is not recognizing your data as a date.
If you want the month from it use –
Right(Left([xact_dat_x],6),2)


"samuel" wrote:

i import a table with this value as the timestamp (seen as a text data type)

[xact_dat_x]
2005112602465800

i want a query to extract the month..

Date: Format(Left([xact_dat_x],8),"mm") gives an error .

help.

  #9  
Old December 28th, 2005, 03:33 AM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default aggregate function

KARL DEWEY wrote:
If you want the month from it use –
Right(Left([xact_dat_x],6),2)



But, Karl, that's just the long way around to the Mid
function that everyone else used.

--
Marsh
MVP [MS Access]
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Update with aggregate MIN function cjmccann Running & Setting Up Queries 10 October 18th, 2005 10:51 PM
How Do You Order an Aggregate Function A Boy Named Joe Setting Up & Running Reports 2 August 17th, 2005 02:46 PM
PLEASE HELP with the SPELLNUMBER function vag Worksheet Functions 0 June 16th, 2005 01:33 PM
Automatically up date time in a cell Mark General Discussion 5 May 12th, 2005 12:26 AM
DISTINCT option of an aggregate function in Access 2003 [email protected] Running & Setting Up Queries 1 May 5th, 2005 04:46 PM


All times are GMT +1. The time now is 08:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.