View Full Version : Format() with Date.Now issue?


Access_guy49
06-21-2011, 05:43 AM
Hey Everyone,
I was wondering if anyone has come accross an issue with the Format Function in which if you use the Date.now as the date, it messes up the date.
Example.
If date.now provides the system date as 20/6/2011
Using the Format( Date.now, "mm/dd/yyyy")
Gets you a random date such as
46/20/2011
I know it's not totally random, the problem is the single digit for the month. It seems to be using a random number to make it a double digit month, but i don't recall this ever happening in VBA in Access..
Any thoughts?

boblarson
06-21-2011, 09:03 AM
In VB.NET, you don't use Format for the date. In VB.NET you would use something like this:

Me.Label1.Text = FormatDateTime(Now(), DateFormat.ShortDate)

dan-cat
06-23-2011, 04:51 AM
"mm" denotes minutes in VB.net, for month use "MM"

Date.Now.ToString("MM/dd/yyyy")

Just use the .ToString() extension method for the date type with the appropriate format, that way you can apply any format you want.

Access_guy49
06-23-2011, 11:11 AM
Thanks guys! both tips helped!