473,386 Members | 1,827 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,386 software developers and data experts.

Date/time with minutes and seconds optional?

I'm using this:
MyDateTimeStr = MyDateTimeVal.ToString("MM-dd-yyyy hh:mm:ss tt");
in C# to convert what I read from a form submit.

What I want is something more flexible where the minutes and seconds are optional.
How to do that?

I want to able to specify several variations as all legal:

6-30-2005 4pm
6-30-2005 4 pm
6-30-2005 4:30 pm
6-30-2005 4:30:15 pm
6-30-2005 4:30:15 p
6-30-05 4:30:15 pm

And similarly with slashes:

6/30/2005 4:30:15 pm
Dec 8 '05 #1
2 1804
oops, copied the wrong line. This is what I'm using:

DateTime LastServiceDateTimeVal = DateTime.ParseExact(InputString,
"MM-dd-yyyy hh:mm:ss tt",null);


Randall Parker wrote:
I'm using this:
MyDateTimeStr = MyDateTimeVal.ToString("MM-dd-yyyy hh:mm:ss tt");
in C# to convert what I read from a form submit.

What I want is something more flexible where the minutes and seconds are
optional. How to do that?

I want to able to specify several variations as all legal:

6-30-2005 4pm
6-30-2005 4 pm
6-30-2005 4:30 pm
6-30-2005 4:30:15 pm
6-30-2005 4:30:15 p
6-30-05 4:30:15 pm

And similarly with slashes:

6/30/2005 4:30:15 pm

Dec 8 '05 #2
Here's a lead [1] to a document. Use the formatters to return your desired
results.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1]
http://www.codeguru.com/Csharp/Cshar...cle.php/c4205/
"Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit .com>
wrote in message news:eQ***************@tk2msftngp13.phx.gbl...
oops, copied the wrong line. This is what I'm using:

DateTime LastServiceDateTimeVal = DateTime.ParseExact(InputString,
"MM-dd-yyyy hh:mm:ss tt",null);


Randall Parker wrote:
I'm using this:
MyDateTimeStr = MyDateTimeVal.ToString("MM-dd-yyyy hh:mm:ss tt");
in C# to convert what I read from a form submit.

What I want is something more flexible where the minutes and seconds are
optional. How to do that?

I want to able to specify several variations as all legal:

6-30-2005 4pm
6-30-2005 4 pm
6-30-2005 4:30 pm
6-30-2005 4:30:15 pm
6-30-2005 4:30:15 p
6-30-05 4:30:15 pm

And similarly with slashes:

6/30/2005 4:30:15 pm

Dec 8 '05 #3

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

Similar topics

7
by: Harag | last post by:
Hi all I think this is in the wrong group but since I don't read others much or code in java script I was wondering if anyone could help me with this small problem, as I code mostly in ASP...
28
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
9
by: ME | last post by:
can someone tell me how to make this first one work??, located here: http://javascript.about.com/library/scripts/blshowdatetime.htm#examplesource This second one, well, dreamweaver eats the code,...
6
by: Mark Reed | last post by:
Hi Guru's, I have created a database to monitor hours I have worked as our payroll department are so crap. I work nights most of the time but occasionally I have to work on days. Between the hours...
1
by: Flipmode | last post by:
I am fairly novice at VB and access in particular and I am having problems trying store a date into database field. This is the scenario I am faced with. I want to when click on a pause button...
0
by: UBI | last post by:
Vorrei suggerire una funzione completa per la differenza fra due date. (questo è codice freeware, niente di illegale) La funzione seguente permette il calcolo di una differenza precisa tra due...
15
by: Cerebral Believer | last post by:
Hi all, I am a newbie to JavaScript and am just trying to get a script going that will write the ful date and time to each webpage as it is viewed. Can anyone point out what mistakes there are...
3
by: dave | last post by:
I need to compute an expiration date based on the number of hours, days, or months purchased. The expiration date needs to be expressed in minutes something like '1260481600'. How can I get the...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.