Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 716
  • Last Modified:

get today day to a variable in vb.net

hi all , how can i get today's day in a variable in vb.net

 Dim dia As New System.DateTime

i need the day for today in dd/mm/aaaa format

thank you a lot
0
Ernesto
Asked:
Ernesto
2 Solutions
 
urir10Commented:
dia = datetime.now()
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
try this
Dim dt As Date = Now
        Me.TextBox1.Text = dt.ToString("dd/MM/yyyy")
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
more clearly
Dim dia As Date = Now
        dia = dia.ToString("dd/MM/yyyy")
        Me.TextBox1.Text = dia
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ZhaolaiCommented:
You can't get a DateTime variable with formatting like "dd/mm/aaaa". A string variable will do, like the one @jtoutou posted. Or
 
Dim dia As String = Today.Date.ToString("dd/MM/yyyy")

0
 
Mohamed AbowardaSoftware EngineerCommented:
Try the following:
Dim d As Date = Now                 'Date
Dim day As Short = d.Date.Day       'Day
Dim month As Short = d.Date.Month   'Month
Dim year As Short = d.Date.Year     'Year

MsgBox(day.ToString("00") & "/" & month.ToString("00") & "/" & year.ToString("0000"))

Open in new window

0
 
ErnestoAuthor Commented:
thank you all
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Or deppending on your system setting (if this is you format ) you can use dia.ToShortDateString (for  variable always as a stirng Variable...)
0
 
Mohamed AbowardaSoftware EngineerCommented:
BTW, the code I posted do the same.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now