0 pts.
0
Q:
Cannot get the current year using vbDate or vbLongDate
VBA
I have tried to get the current year (2005), with the following statements:
helpfield = DatePart("yyyy", vbLongDate)
helpfield = DatePart("yyyy", vbDate)

The first statement gives me the year 1899; in debugging I can see that vbLongDate = 1.
The second statement gives me the year 1900; in debugging I can see that vbDate = 7.

I am running Windows XP Professional, Microsoft Access 2002 (SP3), Microsoft Visual Basic 6.3.

Thanks for any help.
ASKED: Nov 10 2005  3:30 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
0 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
vbLongDate and vbDate are actually constants that will always return the same value: 1 and 7 respectively. vbLongDate is a formatting constant and vbDate is the value representing a date object.

To get the current date and time in VB use the function Now() as follows: helpfield = DatePart("yyyy", Now())

This will correctly return 2005.
Last Answered: Nov 10 2005  11:09 AM GMT by jswalwell   0 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

gerhemmes   0 pts.  |   Nov 10 2005  11:23AM GMT

solved

thank you, jswalwell !

 

vb6 get current year   0 pts.  |   Jul 11 2008  2:58PM GMT

[...] [...]

 
0