473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change Date format

46
Hi all,
How to change a date format?
Example:
6/5/2007
I want to change to 5 June 2007.
I get the date from the calendar. I had change the dateformat in the properties already. But the result still is not what I want. What should I do?
Thanks..
Jun 5 '07 #1
8 4182
Killer42
8,435 Expert 8TB
How to change a date format?
Example:
6/5/2007
I want to change to 5 June 2007.
I get the date from the calendar. I had change the dateformat in the properties already. But the result still is not what I want. What should I do?
What you have is a Date data type. You can use the Format() function to format it however you want.

(This applies to VB6 - not sure how it works in later versions.)
Jun 5 '07 #2
cmrhema
375 256MB
What you have is a Date data type. You can use the Format() function to format it however you want.

(This applies to VB6 - not sure how it works in later versions.)
Try out this

Try this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2. Dim D1 As Date
  3. Dim D2 As String
  4. 'If you keep D2 as Date it will not convert to the required format
  5. D1 = Now
  6. D2 = Format(D1, "dd/mmm/yyyy")
  7. MsgBox D2
  8. End Sub
Jun 5 '07 #3
Killer42
8,435 Expert 8TB
It's true that MsgBox will expect a string. But if you prefer, you can do it in one step, like so...

MsgBox Format(D1, "dd/mmm/yyyy")
or
MsgBox Format(D1, "Short Date")
Jun 5 '07 #4
cmrhema
375 256MB
It's true that MsgBox will expect a string. But if you prefer, you can do it in one step, like so...

MsgBox Format(D1, "dd/mmm/yyyy")
or
MsgBox Format(D1, "Short Date")
What I meant was whenever one formats a date it will be/has to be returned in a string
http://msdn2.microsoft.com/En-US/lib...a0(VS.80).aspx
Jun 5 '07 #5
Killer42
8,435 Expert 8TB
What I meant was whenever one formats a date it will be/has to be returned in a string
http://msdn2.microsoft.com/En-US/lib...a0(VS.80).aspx
Yes, I was just making the point that you can work directly with the returned string - you don't have to assign it to a variable first, unless you want to.
Jun 5 '07 #6
cmrhema
375 256MB
Yes, I was just making the point that you can work directly with the returned string - you don't have to assign it to a variable first, unless you want to.
Oh! I understood what you meant
Jun 6 '07 #7
sierra7
446 Expert 256MB
Check out this
http://www.qualitycodes.com/tutorial...id=9&pageid=52
Thanks for that reference, it summarizes a lot of matters relating to dates.

However, to be pedantic, the OP has requested the full month name with no slashes, so the format would be;-
Expand|Select|Wrap|Line Numbers
  1.  
  2. Msgbox Format(Date,"dd mmmm yyyy") 'not case sensitive
  3.  
with the usual qualification that this is for US/English regional and keyboard settings.

S7
Jan 30 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Karam Chand | last post by:
Hello Is there anyway to change the default date format (possibly in a .ini or .cfg file) from YYYY-MM-DD to another format ? (ie, mm/dd/yyyy or any user-defined format). The useage that I'm...
1
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
4
by: Claudia Fong | last post by:
Hi Is there a way to change a date format dd/mm/yyyy to m/d/yy? I have a textBox where the user should put a date, but no matter what format the user input dd/mm/yyyy or m/d/yy, I need to...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
10
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column...
1
by: Tee GEE | last post by:
I included my VBA below. I would like to change the font of the "strBody" to be Bold, italic, color, etc. The code that I attempted to write is identified by ***. Any help would be appreciated....
4
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
3
by: Bface | last post by:
Hi all, Hope everyone had a good holiday. I am having a difficult time changing the date format of a field from Excel. I have never had this problem before. I link the excel spreadsheet to my DB,...
10
by: mukeshrasm | last post by:
Hi the code written below is for calculating the number of days remain for a particular event based on the specific local time i.e. time in new york or time in london. <style style="text/css">...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.