Formatting a date,
In VB6 I could specify the a date that was so many days from today and change the format of the output in a nice and easy statement: Format(Now - 1, "yyyyMMdd"). I am trying to learn vb2010 and am getting an error on that statement: Operator '-' is not defined for types Date and Integer. Any idea on what the 2010 version of this simple VB6 statement?
New22010
0
Newbie Poster
Recommended Answers
Jump to PostDateAdd(DateInterval.Day,-1,Now())
The first parameter is the interval and you can specify other values for month, year, etc.
Jump to PostIn VB6, the Date type would automagically convert back and forth to a floating-point number, with the integer part representing the day, and the fractional part representing the part of the day (hours, minutes, etc.). When you subtracted a number from a date, you were relying on this behaviour. Pushing …
All 6 Replies
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Nutster
58
Newbie Poster
New22010
0
Newbie Poster
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Nutster
58
Newbie Poster
New22010
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.