quick "the Date" question
VB Code:
M = Month(TheDate)
D = Day(TheDate)
Y = Year(TheDate)
ok, when the user doesn't unput the date I have these run
well my question is on the "year" command, will that be the full "2006" or just "06" and if it is the full 2006 then should I just use the "y=y-2000" or is there a way to make it only give the last two?
Re: quick "the Date" question
It will return 2006. Subtracting 2000 from 2006 would give you 6 and not 06. Since the Year function returns an Integer it will not contain leading zeros. But it all depends on what you want to do with the year, you can use the Format function to display it in any form you like.
Re: quick "the Date" question
when taking a value to display it, in say a listview, what format call would I make to force it to show "06"
Re: quick "the Date" question
Let me first ask you how you have declared the Y, M, and D variables? Using todays date would give M the value of 7, not 07.
Please also tell me exactly how you want the date to be displayed. Is there a special reason for splitting up the year, month, and day? I mean should they be displayed in different columns of a ListView, instead of together?
Re: quick "the Date" question
The date stuff aside, to format a number with exactly two digits, with a leading zero if necessary, you would use:
Format$(The_Number, "00")
Re: quick "the Date" question
What Bruce showed above is correct. However why I asked all questions before giving you that answer is because the Format function returns a string while the Year, Month, and Day functions returns an integer. So you need to declare the variable of the correct type. If you want to handle the date parts as strings you can just as well use the following code instead of using the Year, Month, and Day functions.
VB Code:
Y = Format$(theDate, "yy")
M = Format$(theDate, "mm")
D = Format$(theDate, "dd")
But for the above to work properly the Y, M, and D variables should be declared as strings.