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 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 …
Jump to PostFormat can still be used to format your date as a string, just use the DateAdd function to do this.
Format(DateAdd(DateInterval.Day, -1, Now()), "yyyyMMdd")
You also might want to look at the built-in conversions of Date.toString. Look in the help under Standard Date and Time format Strings.I am still new …
All 6 Replies
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Nutster 58 Newbie Poster
New22010 0 Newbie Poster
Reverend Jim 5,225 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.