Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get today day to a variable in vb.net

Posted on 2010-09-07
8
Medium Priority
?
697 Views
Last Modified: 2012-05-10
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
Comment
Question by:Ernesto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 7

Expert Comment

by:urir10
ID: 33619954
dia = datetime.now()
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33619962
try this
Dim dt As Date = Now
        Me.TextBox1.Text = dt.ToString("dd/MM/yyyy")
0
 
LVL 18

Assisted Solution

by:John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou earned 800 total points
ID: 33620030
more clearly
Dim dia As Date = Now
        dia = dia.ToString("dd/MM/yyyy")
        Me.TextBox1.Text = dia
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 17

Accepted Solution

by:
Zhaolai earned 1200 total points
ID: 33620047
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
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33620052
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
 

Author Closing Comment

by:Ernesto
ID: 33620094
thank you all
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33620098
Or deppending on your system setting (if this is you format ) you can use dia.ToShortDateString (for  variable always as a stirng Variable...)
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33620388
BTW, the code I posted do the same.
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question