473,785 Members | 2,291 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 25118

"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
9446
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
1239
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
2787
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
2469
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
3316
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
19188
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
1999
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
7069
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
2467
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
32957
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
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10085
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
9947
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
8968
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
7494
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
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
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.