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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |