date format

date format

Miguel.CarvajalS34Q6
Advocate Advocate
1,548 Views
7 Replies
Message 1 of 8

date format

Miguel.CarvajalS34Q6
Advocate
Advocate
 

 change the date format; set it to year - month - day

Accepted solutions (1)
1,549 Views
7 Replies
Replies (7)
Message 2 of 8

nedeljko.sovljanski
Advocate
Advocate
Accepted solution
Message 3 of 8

WCrihfield
Mentor
Mentor

 

Dim oNow As String = Now.ToString("yyyy MMMM dd")
MsgBox("oNow = " & oNow)

It appears I was a little slow on the draw. 😉

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 8

Miguel.CarvajalS34Q6
Advocate
Advocate

I don't understand the last part of the code, can you explain me the syntax please

0 Likes
Message 5 of 8

WCrihfield
Mentor
Mentor

I guess it can be quite a bit more complicated than you might expect.  There appears to be tons of ways to manipulate DateTime data into the format you want.  Below are a couple more links that you might find helpful/informational.

Standard date and time format strings 

Custom date and time format strings 

DateTime Struct 

DateTime.ToString Method 

DateTimeFormatInfo Class 

DateTimeFormatInfo.SortableDateTimePattern Property 

DateTimeFormatInfo.UniversalSortableDateTimePattern Property 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 8

oliver_schmid08
Observer
Observer

Hello

 

I want to change date format from dd/mm/yyyy to dd.mm.yyyy.

0 Likes
Message 7 of 8

WCrihfield
Mentor
Mentor

Hi @oliver_schmid08.  Have you read any of the information at the Links posted above, or tried to do that formatting yourself yet?  There are likely several different ways to get to a similar result, depending on what you are doing.  Below are a couple more Links that may be of interest to you in a case like this.  They point to two properties of the DateTimeFormatInfo object, where we can specify which character we want to use as the separator for date and time formatting, and they include some example code.

DateTimeFormatInfo.DateSeparator 

DateTimeFormatInfo.TimeSeparator 

And below is just one possible way to get to that type of result, but likely not the most proper or intuitive way.

Dim oDate As Date = DateAndTime.Today
Dim sDate As String = oDate.Day.ToString("00") & "." & oDate.Month.ToString("00") & "." & oDate.Year.ToString("0000")
MsgBox("Date = " & sDate,,"")

Edit:  The following may be the shortest way to get that type of result, at least for me, but maybe not for everyone.  The local language and culture where you are may play a role in how this works.

MsgBox("Date = " & Today.ToString("dd.MM.yyyy"),,"")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 8

CGBenner
Community Manager
Community Manager

@oliver_schmid08 

Hi, were you able to resolve this from the answer given by @WCrihfield 

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes