473,889 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert date and time formats

It used to work in vb6. I don't know the syntax in vb.net

current date and time....

format (cstr(date),"DD MMYY")

format(cstr(tim e),"HHMM")

thanks
Nov 21 '05 #1
9 25146

"romy" <ro******@Power up1.com> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
It used to work in vb6. I don't know the syntax in vb.net

current date and time....

format (cstr(date),"DD MMYY")

format(cstr(tim e),"HHMM")

thanks


Dim date As DateTime = DateTime.Parse( "August 10, 1980 10:10:23 AM")

date.ToString(" ddMMyy")
date.ToString(" hhmm")

HTH,
Mythran

Nov 21 '05 #2
"romy" <ro******@Power up1.com> wrote in message news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
It used to work in vb6. I don't know the syntax in vb.net

current date and time....

format (cstr(date),"DD MMYY")

format(cstr(tim e),"HHMM")

thanks


Dim sDate As String = Format(DateTime .Now, "ddMMyy") OR

Dim sDate As String = Format(DateTime .Today, "ddMMyy")

Dim sTime As String = Format(DateTime .Now, "hhmm")

--

Al Reid
Nov 21 '05 #3
"romy" <ro******@Power up1.com> schrieb
It used to work in vb6. I don't know the syntax in vb.net

current date and time....

format (cstr(date),"DD MMYY")
Now.ToString("d dMMyy")
format(cstr(tim e),"HHMM")


Now.ToString("H Hmm")

Have a look at the Date date type and it's members, including shared
members. The type Date is exactly the same as the type System.DateTime .

- Current date and time: Date.Now (equal to
Microsoft.Visua lBasic.DateAndT ime.Now)
- Current date: Date.Today (equal to
Microsoft.Visua lBasic.DateAndT ime.Today)
- Current time: Date.TimeOfDay (same time as
Microsoft.Visua lBasic.DateAndT ime.TimeOfDay, but different data type)
Armin

Nov 21 '05 #4
"romy" <ro******@Power up1.com> schrieb:
It used to work in vb6. I don't know the syntax in vb.net

current date and time....

format (cstr(date),"DD MMYY")

format(cstr(tim e),"HHMM")


'Dim s As String = date.ToString(< format>)'. For a list of possible formats
take a look at this article:

..NET Framework Developer's Guide -- Date and Time Format Strings
<URL:http://msdn.microsoft. com/library/en-us/cpguide/html/cpconDateTimeFo rmatStrings.asp >

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5
Romy,

Be aware that the article that Herfried is showing is (although a very good
article) based on the general system.net posibilities. Visual Basic has
strong methods for date and time extra above that. As Armin told already.

In my opinion is there no reason why VBNet programmers would not use the
full strenght of Visual.Basic net instead of that only the subset now showed
by Herfried in these pages.

Just my thought,

Cor
Nov 21 '05 #6
"Cor Ligthert" <no************ @planet.nl> schrieb:
Be aware that the article that Herfried is showing is (although a very
good article) based on the general system.net posibilities. Visual Basic
has strong methods for date and time extra above that. As Armin told
already.


Wake up, Cor. We are talking about converting a date to a string only.
VB.NET's methods for doing that are not stronger than those provided by the
..NET Framework.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
Herfried,
Wake up, Cor. We are talking about converting a date to a string only.
VB.NET's methods for doing that are not stronger than those provided by
the .NET Framework.


I wrote this expressely because you are writting this forever in this way
about other functions as Mid, Len, and whatever.

However when the "parse" comes than you have another opinion.

The CDate is not a *strong* command, however just like the ones you are
forever mentioning in other situations, (which I don't like because of the
First as indexer), do I find this one extremly handy. I have nothing to
remember beside four characters "CDate" and than it does everything
accoording the language/culture settings of a computer.

You write forever "why not use VB methods when there are VB methods". I
never understand why in this case a "system" method should be used as you
always tell.

:-)

Cor


Nov 21 '05 #8
Cor,

"Cor Ligthert" <no************ @planet.nl> schrieb:
Wake up, Cor. We are talking about converting a date to a string only.
VB.NET's methods for doing that are not stronger than those provided by
the .NET Framework.
I wrote this expressely because you are writting this forever in this way
about other functions as Mid, Len, and whatever.


I use VB.NET's own functions whenever possible.
However when the "parse" comes than you have another opinion.


I hardly ever parse a date without specifying a certain date format.
Typically in Windows Forms applications processing user input I prefer a
DateTimePicker control for choosing dates over a textbox and string parsing.
When reading dates from a file, I use 'DateTime.Parse Exact' to make sure the
data is read the way I want it to be read on every system.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schrieb
I hardly ever parse a date without specifying a certain date format.
Typically in Windows Forms applications processing user input I
prefer a DateTimePicker control for choosing dates over a textbox
and string parsing. When reading dates from a file, I use
'DateTime.Parse Exact' to make sure the data is read the way I want
it to be read on every system.

Of course! DateTimePicker! That's the solution! :-))
Armin
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9449
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
2
1244
by: Andrew J Gray | last post by:
Guys Anyone know how to go about customizing the display of the date/time formats? This is related to Dreamweavers binding panels but if their is more fundemental info available for this I cant find it. Typically im trying to do the following: In the table the date is recorded, as an example: 09/03/2003 How can i display this on an asp.net page as say Sep 09 2004 Note Short month name.
4
2794
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway, everything works fine when testing in my computer. However, when i uploaded the web site to my hosting space in the date/time appears as
2
2475
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my time field then this format gives the liberty to record times uptill a figure of 59 in different sub-formats, whereas i want the format to be able to record the times like 80:35 or 1:10 or 1138:00. which means that i have these many hours on a...
3
3323
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when the field should only be showing one or the other (date or time). Even on the back end of the database where the column properties are, I have chosen the smallest date/time formats. When the aspx page runs, it shows the date and time (ie:in a...
5
19190
nirmalsingh
by: nirmalsingh | last post by:
i am getting date format in string as 30-11-2006 05:59:44 PM . i want to convert in the format of yyyy-mm-dd hh:mm:ss to sore it in mysql database. Help me with sample coding plz..
7
2006
by: JamesG | last post by:
Hi, I need to convert the current time to the format "hh:mm:ss" and date to the format "yyyy-MM-dd". The result of both conversions needs to be of System.DateTime format. I've tried using DateTime.ParseExact and DateTimeFormatInfo but failed, most examples I see convert the final result to a string... I dont want that!
11
7076
by: robtyketto | last post by:
Greetings, I'm using Flash MX connecting to an MS Access database via JET. I've stored dates using Flash/Jet into my database as 'dd/mm/yyyy hh:mm:ss' into a DATE/TIME field. However I can't update because of the WHERE clause as I am not specifying the date correctly. I believe syntax wise I need to use # and specify it in american format mm/dd/yyyy hh:mm:ss. I have the code below working :- mdm.Database.MSAccess.runQuery("UPDATE...
3
2472
by: ssmeshack | last post by:
Hi all, Im have a problem here. Im using VWD 2008 (c#) and Mysql 2005. I dont know how to convert datetime data that i retrieve from mysql database to only date or time. Can anyone help me? Here is something that i tried to do. Date1.Text = Convert.ToString(reader, (MMMM d, yyyy)); //"MMMM d, yyyy", Time1.Text = Convert.ToString(reader, (HH:mm ss tt)); //"HH:mm ss tt", but it didnt work even when i try to put format in of reader.
4
32971
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used the MYSQL Tables DateTime Type as Text. Time-formet 1. 04:02:27 16/01/2009 Time-formet 2. 16/01/2009 13:53:19 Time-formet 3. 00901E+13 Time-formet 4. Wed Jan 14 00:09:09 BDT 2009
0
9969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10794
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10896
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10443
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9612
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7999
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3257
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.