Solved

get today day to a variable in vb.net

Posted on 2010-09-07
8
683 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:edo60
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 200 total points
ID: 33620030
more clearly
Dim dia As Date = Now
        dia = dia.ToString("dd/MM/yyyy")
        Me.TextBox1.Text = dia
0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 300 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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:edo60
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now