• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 708
  • 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

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