ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Year showing 1899 instead of 2009 (https://www.excelbanter.com/excel-programming/424563-year-showing-1899-instead-2009-a.html)

Bob Zimski

Year showing 1899 instead of 2009
 
How do I get the following to give me 2009 instead of 1899 in immediate window?

? Year(today)
produces 1899 rather than 2009



Rick Rothstein

Year showing 1899 instead of 2009
 
TODAY is a worksheet function, not a VB one. Use either one of these
instead...

? Year(Now)

? Year(Date)

--
Rick (MVP - Excel)


"Bob Zimski" wrote in message
...
How do I get the following to give me 2009 instead of 1899 in immediate
window?

? Year(today)
produces 1899 rather than 2009




egun

Year showing 1899 instead of 2009
 
Debug.Print Year(Now)

HTH,

Eric

"Bob Zimski" wrote:

How do I get the following to give me 2009 instead of 1899 in immediate window?

? Year(today)
produces 1899 rather than 2009



Jim Cone[_2_]

Year showing 1899 instead of 2009
 
Or try...
?year([today()])
--
Jim Cone
Portland, Oregon USA


"Bob Zimski"

wrote in message
How do I get the following to give me 2009 instead of 1899 in immediate window?

? Year(today)
produces 1899 rather than 2009



Dick Kusleika[_4_]

Year showing 1899 instead of 2009
 
On Mon, 23 Feb 2009 13:48:35 -0500, "Rick Rothstein"
wrote:

TODAY is a worksheet function, not a VB one. Use either one of these
instead...

? Year(Now)

? Year(Date)


In addition, under VBE - Tools - Options, check Require Variable
Declaration. That way VBA would not try to interpret 'today' as a variable.
And it's just good practice.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com


All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com