Solved

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

Posted on 2004-10-14
8
1,591 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
Comment Utility
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
Comment Utility
0
 
LVL 48

Accepted Solution

by:
Mikal613 earned 85 total points
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 10

Expert Comment

by:jagadeesh_motamarri
Comment Utility



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
Comment Utility
hi
  jimbobmcgee, u get the point
u were fast
;-)
0
 
LVL 16

Expert Comment

by:jimbobmcgee
Comment Utility
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
Comment Utility
hi jimbobmcgee
u r right
thanks
;-)
Shiju
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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

12 Experts available now in Live!

Get 1:1 Help Now