473,396 Members | 2,082 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,396 software developers and data experts.

Using arrays to display a date.

Hi.

Any suggestions on how I might build a form which allows my user to enter a
number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya
Nov 17 '05 #1
5 6341
Hi,

Why an array?

I guess that the number you will enter will mean the day offset in the year,
if that is what you want I'm sure there exist several ways, from the top of
my head I think of this:

DateTime dt = new DateTime( DateTime.Now.Year, 1, 1) ;
dt = dt.AddDays( number_from_1_to_365 );
Again, no idea why the use of the array

cheers,
"Vikas Arya" <ar*******@hotmail.com(donotspam)> wrote in message
news:43**********************************@microsof t.com...
Hi.

Any suggestions on how I might build a form which allows my user to enter
a
number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya

Nov 17 '05 #2
You really don't need an array to do this, I'm assuming 1 would be Jan 1st
of the current year and 365 would be dec. 31st of the current year:

DateTime startDate = DateTime.Parse("01/01/" +
DateTime.Now.Year.ToString()); //Get the first of the current year
int daysToAdd = int.Parse(textBox1.Text) - 1; //this will allow for 1 to
give you 1/1/2005
DateTime newDate = startDate.AddDays(daysToAdd);
MessageBox.Show(newDate.ToString());

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Vikas Arya" <ar*******@hotmail.com(donotspam)> wrote in message
news:43**********************************@microsof t.com...
Hi.

Any suggestions on how I might build a form which allows my user to enter a number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya

Nov 17 '05 #3
Also if you HAVE to do it with an array here is an example, meant to add
this with last post, but got pulled away to a meeting:

DateTime startDate = DateTime.Parse("01/01/" +
DateTime.Now.Year.ToString());
ArrayList dates = new ArrayList();
for (int i = 0; i <= 364; i++)
{
dates.Add(startDate.AddDays(i));
}

//Pull the date directly from the array list
MessageBox.Show(((DateTime)dates[int.Parse(textBox1.Text)-1]).ToString());

//convert the array list to an array and get the date that way
DateTime[] dateArray = new DateTime[dates.Count];
dates.CopyTo(dateArray);
MessageBox.Show(dateArray[int.Parse(textBox1.Text)-1].ToString());

--
Thanks

"Wayne" <Me******@community.nospam> wrote in message
news:#g**************@TK2MSFTNGP10.phx.gbl...
You really don't need an array to do this, I'm assuming 1 would be Jan 1st
of the current year and 365 would be dec. 31st of the current year:

DateTime startDate = DateTime.Parse("01/01/" +
DateTime.Now.Year.ToString()); //Get the first of the current year
int daysToAdd = int.Parse(textBox1.Text) - 1; //this will allow for 1 to
give you 1/1/2005
DateTime newDate = startDate.AddDays(daysToAdd);
MessageBox.Show(newDate.ToString());

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Vikas Arya" <ar*******@hotmail.com(donotspam)> wrote in message
news:43**********************************@microsof t.com...
Hi.

Any suggestions on how I might build a form which allows my user to
enter a
number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya


Nov 17 '05 #4
Thanks.

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Why an array?

I guess that the number you will enter will mean the day offset in the year,
if that is what you want I'm sure there exist several ways, from the top of
my head I think of this:

DateTime dt = new DateTime( DateTime.Now.Year, 1, 1) ;
dt = dt.AddDays( number_from_1_to_365 );
Again, no idea why the use of the array

cheers,
"Vikas Arya" <ar*******@hotmail.com(donotspam)> wrote in message
news:43**********************************@microsof t.com...
Hi.

Any suggestions on how I might build a form which allows my user to enter
a
number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya


Nov 17 '05 #5
Thanks. You were very helpful.

"Wayne" wrote:
Also if you HAVE to do it with an array here is an example, meant to add
this with last post, but got pulled away to a meeting:

DateTime startDate = DateTime.Parse("01/01/" +
DateTime.Now.Year.ToString());
ArrayList dates = new ArrayList();
for (int i = 0; i <= 364; i++)
{
dates.Add(startDate.AddDays(i));
}

//Pull the date directly from the array list
MessageBox.Show(((DateTime)dates[int.Parse(textBox1.Text)-1]).ToString());

//convert the array list to an array and get the date that way
DateTime[] dateArray = new DateTime[dates.Count];
dates.CopyTo(dateArray);
MessageBox.Show(dateArray[int.Parse(textBox1.Text)-1].ToString());

--
Thanks

"Wayne" <Me******@community.nospam> wrote in message
news:#g**************@TK2MSFTNGP10.phx.gbl...
You really don't need an array to do this, I'm assuming 1 would be Jan 1st
of the current year and 365 would be dec. 31st of the current year:

DateTime startDate = DateTime.Parse("01/01/" +
DateTime.Now.Year.ToString()); //Get the first of the current year
int daysToAdd = int.Parse(textBox1.Text) - 1; //this will allow for 1 to
give you 1/1/2005
DateTime newDate = startDate.AddDays(daysToAdd);
MessageBox.Show(newDate.ToString());

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute.

But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Vikas Arya" <ar*******@hotmail.com(donotspam)> wrote in message
news:43**********************************@microsof t.com...
Hi.

Any suggestions on how I might build a form which allows my user to

enter
a
number from 1-365 and return a date in the 'mm/dd' format?

I would like to use an array to do this. Thanks.
--
Thanks,

Vikas Arya



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
2
by: Dave Smithz | last post by:
Hi there. Because of the lack of a Union query in MySQL 3 I have decided to take the approach where I populate two arrays with values from similar tables in DB. In this case they are `courses`...
4
by: dmiller23462 | last post by:
Somebody take a look and give me any suggestions? My brain is nuked... Here's my deal....I have online submission forms on my intranet at work here....I am appending to an Access DB with the...
4
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
5
by: Chris | last post by:
Hi, 1) I find the notation for managed arrays in C++.NET very confusing : Sometimes is it not necessary to use the pointer notation ==> short pS2 __gc = new short __gc; Sometimes it is !!!...
1
by: Adrienne Boswell | last post by:
I have a form which I am letting the user enter more than one event at a time. I need to check whether one date is less than another. If the display to date is earlier than the event date, then...
5
by: ljungmichel | last post by:
I really need some help with my project. It should be a very easy program, but no matter what I read online or in my books, I don't seem to be able to grasp the idea of arrays. I don't get how to use...
3
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display an array of objects using a GUI. My instructions are that the CD class and it's sublcass don't need to change I just need to modify class CDInventory to include the GUI. I'm not...
2
by: theblissfulwizard | last post by:
FYI - New to ASP I'm trying to get multiple values from checkboxes inserted into a table using arrays. I'm using VBscript - ASP 1.1 (not 2.0) and here is what I want to do. I have a page that...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.