I saw previous solutions to convert a month number (1) to a month name (January). I have a database with 200+ dates. In a query, I use the "Part" function DatePart("m",[full_date]), to extract the month (number) and all month extracts worked correctly (they returned the correct numerical month). However, when I attempted adding a field in the query to format that extracted month to a month name, it only returned January and December - for all 200+ records. What did I do wrong and how can I correctly get the month name to appear.
thanks
Without a good idea of your code structure I would say simply replace your - DatePart("m",[full_date])
with - Format([full_date],"mmmm")
wherever you have it in your code.
-AJ
12 23148
Be Borth,
You need to show us what you did, not just tell us, so that we can review it and offer up a possible solution.
-AJ
Thanks AJ - I'm happy to do that, but the database contains a lot of personal information (names, birthdates, etc) that I would be uncomfortable posting on a public website. Any suggestions?
ben
All I need to see is the function you are using to convert the date. Perhaps your DatePart function along with whatever you are using to convert the DatePart to a date name. Just copied and pasted into the thread, also note, please use the [code] brackets when posting code.
-AJ
Format([full_date],"mmmm") should do it for you.
Welcome to Bytes!
Linq ;0)>
Ok, AJ, thanks. The datafile has a field "full_date" which might be 1/8/1953 for example. In the query, I used the DatePart function to extract the month number in the following way [event_date_month: DatePart("m",[full_date])]. This successfully returns the correct numerical value for the months. However, when I try to create a new field in the query to convert that value to a month name using the Format function I only get "December" or "January". The same thing happens if I try to change the format of "event_date_month" in the query or the report using the properties drop-down menu
Let me know if missinglinq's code works for what you are doing.
-AJ
thanks Linq - I've seen that response before and I'm not sure where to put that code. Do I create a new field or where exactly do I embed the code Format([full_date],"mmmm") in the query? Sorry for being kinda slow on the uptake
Without a good idea of your code structure I would say simply replace your - DatePart("m",[full_date])
with - Format([full_date],"mmmm")
wherever you have it in your code.
-AJ
It works! Thanks AJ, and thanks Linq!!
we can use this code -
monthname(datepart("m",[full_date]))
-
ahmedtharwat19,
First, this is a five year old thread, so the OP probably has lost oversight of this question long ago.
Second, ajalwaysus' answer in Post #9, not only was selected as a correct answer, but is actually the "best" answer, as your solution causes the system to utilize two functions rather than just one. one iteration may only take a few milliseconds longer, but if there were millions of dates to transpose, your solution would take approximately twice as long.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mauro Baraldi |
last post by:
Hello World !
Someone can help how to convert a number to it name. Well I'll explain...
11 -> leven.
48 -> forty eight.
Something like it.
Thanks
|
by: Christopher Benson-Manica |
last post by:
What would be the best way to convert a month number to its corresponding
string? I.e, 3 -> 'March'. Is there a builtin function or must I use a
lookup table or something?
--
Christopher...
|
by: Wayfarer |
last post by:
I've built a report using a aggregate query that is grouped by Month +
Year, Program and Name. When I feed the date ranges as query
parameters, it will very properly print out a report that shows...
|
by: whatluo |
last post by:
Hi, all
I'm now working on a program which will convert dec number to
hex and oct and bin respectively, I've checked the clc but with no
luck, so can anybody give me a hit how to make this done...
|
by: Bill |
last post by:
Hello --
I'm parsing the output of the finger command, and was wondering
something...If I'm given a month abbrievation (such as "Jan"), what's
the best way to figure out the month number? I see...
|
by: Aussie Rules |
last post by:
Hi,
How do I extract just the month part of a date. Say for example I wanted to
get the value of 6 (as in sixth month) from todays date.
Regards
|
by: CindySue |
last post by:
Hello--I've got a query that uses DatePart("m",) to select records for a particular month, and then a report based on that query. I'd like to be able to create a field in the report that says what...
|
by: girl23 |
last post by:
I am using a function prototype to convert month number to month name.
basically you ask the compiler to enter int from 1 to 12 and then convert it.
printMonth ( number ); is the prototype and...
|
by: antonopn |
last post by:
Hello to all!
I'm trying to make a very difficult report. I want to present sales of some products within an year but month-to-month.
lets say that the table would be like this...
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
| |