Tamseyc
Tamseyc

Reputation: 445

Getting the current date in visual Basic 2008

I dont know how to get the current date in visual basic 2008. Here is a sample code

regDate = Format(Date.Now(), "ddMMMyyyy")

The output is like 7/02/1900

Need help

Upvotes: 5

Views: 208884

Answers (5)

user3882642
user3882642

Reputation: 31

Dim regDate As Date = Date.Now.date

This should fix your problem, though it's 2 years old!

Upvotes: -2

blackbada_cpp
blackbada_cpp

Reputation: 432

If you need exact '/' delimiters, for example: 09/20/2013 rather than 09.20.2013, use escape sequence '/':

Dim regDate As Date = Date.Now()
Dim strDate As String = regDate.ToString("MM\/dd\/yyyy")

Upvotes: 1

Anirudh
Anirudh

Reputation: 271

User can use this

Dim todaysdate As String = String.Format("{0:dd/MM/yyyy}", DateTime.Now)

this will format the date as required whereas user can change the string type dd/MM/yyyy or MM/dd/yyyy or yyyy/MM/dd or even can have this format to get the time from date

yyyy/MM/dd HH:mm:ss 

Upvotes: 27

Mark Hurd
Mark Hurd

Reputation: 10931

You may just want:

Dim regDate As Date = Date.Today()

Upvotes: 2

Boeckm
Boeckm

Reputation: 3312

Try this:

Dim regDate as Date = Date.Now()
Dim strDate as String = regDate.ToString("ddMMMyyyy")

strDate will look like so: 07Feb2012

Upvotes: 9

Related Questions