473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

convert month number to month name

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
Sep 16 '09 #1

✓ answered by ajalwaysus

Without a good idea of your code structure I would say simply replace your
Expand|Select|Wrap|Line Numbers
  1. DatePart("m",[full_date])
with
Expand|Select|Wrap|Line Numbers
  1. Format([full_date],"mmmm")
wherever you have it in your code.

-AJ

12 23148
ajalwaysus
266 Expert 100+
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
Sep 16 '09 #2
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
Sep 16 '09 #3
ajalwaysus
266 Expert 100+
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
Sep 16 '09 #4
missinglinq
3,532 Expert 2GB
Format([full_date],"mmmm") should do it for you.

Welcome to Bytes!

Linq ;0)>
Sep 16 '09 #5
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
Sep 16 '09 #6
ajalwaysus
266 Expert 100+
Let me know if missinglinq's code works for what you are doing.

-AJ
Sep 16 '09 #7
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
Sep 16 '09 #8
ajalwaysus
266 Expert 100+
Without a good idea of your code structure I would say simply replace your
Expand|Select|Wrap|Line Numbers
  1. DatePart("m",[full_date])
with
Expand|Select|Wrap|Line Numbers
  1. Format([full_date],"mmmm")
wherever you have it in your code.

-AJ
Sep 16 '09 #9
It works! Thanks AJ, and thanks Linq!!
Sep 16 '09 #10
we can use this code
Expand|Select|Wrap|Line Numbers
  1. monthname(datepart("m",[full_date]))
  2.  
Oct 21 '14 #11
twinnyfo
3,653 Expert Mod 2GB
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.
Oct 21 '14 #12
@ahmedtharwat19
Ahmed,

Thank you very much
Feb 3 '19 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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
2
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...
1
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...
7
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...
10
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...
3
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
2
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...
5
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...
3
antonopn
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... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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,...

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.