Solved

get today day to a variable in vb.net

Posted on 2010-09-07
8
680 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

10 Experts available now in Live!

Get 1:1 Help Now