Setting-up date

pasensyoso_manigbas

Well-known member
Joined
May 19, 2006
Messages
64
Programming Experience
Beginner
hi mods,

i would just wanna improve my code in setting-up the date.
I already get this using selection structure but its too long..

heres what i want to do:

If now.day >1 then
'here i want to set the date to the 20th...
end if

ideas would be great....:D
 
Please be clear with your questions. You say you want to set the date to the 20th. The 20th of what? Do you mean that you want to set the day of some existing Date object, or are you talking about setting the current system date, or something else?
 
i mean i want to set the date to the 20th of the current month.....
 
Did I metion that you should be clear? What does "the date" mean? Are you talking about a Date object in your code or do you mean you want to set the system date or something else because there is no indication in either of your posts. We don't read minds.
 
oopss... sorry..
i havent indicated it that it is the date object in my code...

the date object in my code will be set to the 20th...thats what im trying to say...
 
So you're saying that you have a Date object in your code and, if the day number of today's date is greater than one then you want the day number of this Date object to be set to twenty, correct? That means that if today is the first of any month the Date object will be unaffected, but otherwise it will be set to the twentieth of whichever month it already represents. You cannot set properties of a Date object directly. You would either need to use methods like AddDays to add a positive or negative number of days or, as Paszt suggests, create a new Date object specifying the appropriate Day and using properties of the existing Date object for the other parameters, e.g.
VB.NET:
If Date.Today.Day > 1 Then
    myDate = New Date(myDate.Year, myDate.Month, 20)
 
Back
Top