By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,362 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,362 IT Pros & Developers. It's quick & easy.

Excel YEAR function in vb.net

P: n/a
Hello.

I want to use the excel function Year( ) (or Day, Month, Minute etc...)
in a Visual Basic .net application.

How can i do this?
I tried Excel.WorksheetFunction but this class doesn't contain these
functions.
Is there a similar function in vb.net ? (that take as an argument a single
number, like in excel)

Any help will be much appreciated.

Thank you,
Vasilis
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Hi,

The datetime class has a year function. Not sure if that is exactly
what you are looking for.

http://msdn.microsoft.com/library/de...syeartopic.asp

Ken
---------------------
"Vasilis X" <so*****@somewhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hello.

I want to use the excel function Year( ) (or Day, Month, Minute etc...)
in a Visual Basic .net application.

How can i do this?
I tried Excel.WorksheetFunction but this class doesn't contain these
functions.
Is there a similar function in vb.net ? (that take as an argument a single
number, like in excel)

Any help will be much appreciated.

Thank you,
Vasilis

Nov 21 '05 #2

P: n/a
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Hi,

The datetime class has a year function. Not sure if that is
exactly
what you are looking for.

http://msdn.microsoft.com/library/de...syeartopic.asp

Ken
---------------------
"Vasilis X" <so*****@somewhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hello.

I want to use the excel function Year( ) (or Day, Month, Minute etc...)
in a Visual Basic .net application.

How can i do this?
I tried Excel.WorksheetFunction but this class doesn't contain these
functions.
Is there a similar function in vb.net ? (that take as an argument a single
number, like in excel)

Any help will be much appreciated.

Thank you,
Vasilis

Nov 21 '05 #3

P: n/a
"Vasilis X" <so*****@somewhere.com> wrote in message news:OI**************@TK2MSFTNGP09.phx.gbl...
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.


Look at the Date.FromOADate method.

Now.ToOADate will give a double (38561.319517303244) that represents the date in the format you are looking for. To get the Year from that double you can use the following:

Date.FromOADate(38561.319517303244).Year

I hope that helps.

--
Al Reid

Nov 21 '05 #4

P: n/a
Thank you !
That is exactly what i was looking for !

"Al Reid" <ar*****@reidDASHhome.com> wrote in message news:e6**************@TK2MSFTNGP14.phx.gbl...
"Vasilis X" <so*****@somewhere.com> wrote in message news:OI**************@TK2MSFTNGP09.phx.gbl...
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.


Look at the Date.FromOADate method.

Now.ToOADate will give a double (38561.319517303244) that represents the date in the format you are looking for. To get the Year from that double you can use the following:

Date.FromOADate(38561.319517303244).Year

I hope that helps.

--
Al Reid

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.