datetime manipulation

Hi there!

I′m a newcomer, so I′m not sure this is the correct thread...sorry if it′s not...

I have the following problem: I need to show in a windows Form the conversion from a normal dd/mm/yyyy shown in a date time picker to two textboxes (and viceversa). The first containing the day of the year (from 1 to 366) and the second the year itself (this oe is easy!).

For example: txtdayofyear.text = "360", txtyear.text="2006" ->> Datetimecontrol.value="26/12/2006"

My problem grows as i need to convert from one format to another in both senses, depending of what button the user presses.

I have found a Date "dayofyear" funvtion, which gives me the partial solution, but I still don′t know how to convert from de "360" "2006" to "26/12/2006"

Thanks a lot to anybody who helps!!!

Mikel

[1008 byte] By [mikelbelaus] at [2007-12-24]
# 1

Use to 2006 year to create a new datevariable of 01/01/year and then use the adddays method. ie:

Dim D as new Date(2006, 1,1)

D.AddDays(360)

Msgbox D.ToString

TaDa at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks TaDa,

your hint was really close. I got the final solution using the AddDays function (reading the .Net Help carefully)

I typed your example and didn′t work out the firs time until I realizad the AddDays doesn′t change the datetime value. Instead it returns the new value...

This is how it works:

Dim D As New Date(2006, 1, 1)

Dim nueva As New Date

MsgBox(D.ToString)

nueva = D.AddDays(360)

MsgBox(nueva.ToString)

MsgBox(D.ToString)

mikelbelaus at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...