Solved

is posible convert mm/dd/yyyy to dd/mm/yyyy in visual basic 6.0?

Posted on 2004-10-14
8
1,598 Views
Last Modified: 2008-03-10
need to convert a north american date format (mm/dd/yyyy) to a chilean date format (dd/mm/yyyy)

is this posible?

thanks a lot!

matt.
0
Comment
Question by:matthews_30
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12309009
Try

    a = "11/26/2004"    'DATE IN US FORMAT - 26-NOV-2004
    d = Format(a, "dd/mm/yyyy")     'YOUR DATE FORMAT

or

    a = "11/26/2004"     'DATE IN US FORMAT - 26-NOV-2004
    d = CDate(a)      'DATE IN FORMAT OF SYSTEM

HTH

J.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12309012
0
 
LVL 48

Accepted Solution

by:
Mikal613 earned 85 total points
ID: 12309032
Printing Formatted Dates and Times
To print formatted dates and times, use the Format function with symbols representing date and time. These examples use the Now and Format functions to identify and format the current date and time. The following examples assume that the Regional Settings dialog box of the Windows Control Panel is set to "English(United States)".

Format syntax Result
Format(Now, "m/d/yy") 1/27/93
Format(Now, "dddd, mmmm dd, yyyy") Wednesday, January 27, 1993
Format(Now, "d-mmm") 27-Jan
Format(Now, "mmmm-yy") January-93
Format(Now, "hh:mm AM/PM") 07:18 AM
Format(Now, "h:mm:ss a/p") 7:18:00 a
Format(Now, "d-mmmm h:mm") 3-January 7:18


By using the Now function with the format "ddddd" and "ttttt, " you can print the current date and time in a format appropriate for the selection in the Regional Settings dialog box of the Windows Control Panel.

Country Format syntax Result
Sweden Format(Now, "ddddd ttttt") 1992-12-31 18.22.38
United Kingdom Format(Now, "ddddd ttttt") 31/12/92 18:22:38  
Canada (French) Format(Now, "ddddd ttttt") 92-12-31 18:22:38
United States Format(Now, "ddddd ttttt") 12/31/92 6:22:38 PM
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 12310474



c Displays the date and time.
d Displays the day as a number without a leading zero.
dd Displays the day as a number with a leading zero.
ddd Displays the day as an abbreviation (eg. Mon).
dddd Displays the day as text (eg. Monday).
ddddd Displays the complete date in short format.
dddddd Displays the complete date in long format.
w Displays the day of the week as a number (eg. Sunday = 1).
ww Displays the week of the year as a number.
m Displays the month as a number without a leading zero.
mm Displays the month as a number with a leading zero.
mmm Displays the month as an abbreviation (eg. Jan).
mmmm Displays the month as text (eg. January).
q Displays the quarter of the year (1 - 4).
y Displays the day of the year (1 - 366).
yy Displays the year with two digits.
yyyy Displays the year with four digits.
h Displays the hour without a leading zero.
Hh Displays the hour with a leading zero.
N Displays the minute without a leading zero.
Nn Displays the minute with a leading zero.
S Displays the seconds without a leading zero.
Ss Displays the seconds with a leading zero.
ttttt Displays the complete time according to the locale.
AM/PM
am/pm Displays either a lowercase or uppercase AM or PM adornment for 12-hour formatted time, according to which expression is used.
eg. Format(Now, "Hh:Nn:Ss AM/PM").




some more formats...

Format(Now, “m/d/yy”) 1/27/99
Format(Now, “dddd, mmmm dd, yyyy”) Wednesday, January 27, 1999
Format(Now, “d-mmm”) 27-Jan
Format(Now, “mmmm-yy”) January-99
Format(Now, “hh:mm AM/PM”) 07:18 AM
Format(Now, “h:mm:ss a/p”) 7:18:00 a
Format(Now, “d-mmmm h:mm”) 3-January 7:18




u can use any combination of ur choice...


0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12310714
hi
  jimbobmcgee, u get the point
u were fast
;-)
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12317551
Thanks, shijusn.  A couple of things to note when using format():

    1.  It will take the date in whichever format it is recognised by the system and display it as per your specification.  Be
         careful, still, when dealing with dates such as 02/10/2004 or 11/10/1995, etc -- it depends on your system settings
         as to what part of the date is recognised as what.

    2.  The results of the available formatting are limited depending on the variable type to which you are storing it.  If you
         are storing the formatted result in a Date variable, you may find it only viewable as dd/mm/yyyy or mm/dd/yyyy.  To
         use formats such as mmm or mmmm, you will have to store as a String but this can limit your date calculations, if
         you do any.

HTH

J.
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 12345588
hi jimbobmcgee
u r right
thanks
;-)
Shiju
0

Featured Post

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Concatenate 2 userform comboboxes to a userform text box 4 64
to transfer string from C lanaguage to VBA 4 66
VB6 - Convert HH:MM into Decimal 8 56
TT Auto Dashboard 13 92
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 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