Use Regex.IsMatch To Validater Time Format (HH:mm)?

Apr 28, 2010

I would like to make sure a time with correct format (HH:mm)

this is my code

bool timeCheck = true;
string[] time = ArrivalTIME.Text.Split(':');
if (time.Length > 2)
{
if (time[0].ToString()< 0 || time[0].ToString() > 23)
timeCheck = false;
if (time[1].ToString() < 0 || time[1].ToString() > 59)
timeCheck = false;
}
else
timeCheck = false;

but this code will cause some problem ArrivalTime.Text = "aa:bb" caused syntax error..

just wondering would this check done by Regex ?

View 4 Replies


Similar Messages:

.net - C# - Faster: String.Contains() Or Regex.isMatch()?

Jul 6, 2010

Possible Duplicate: Regex.IsMatch vs string.Contains Which is faster, preferable and why?What the difference in mechanisms between two?I need to search for some values from UserAgent, most of values can be used without wildcards (e.g. if I want to catch cellular phones I search for iPhone instead of *iPhone* wildcards).

View 1 Replies

C# - Format Ssn Using Regex

Mar 10, 2011

I need regex in c sharp to display SSN in the format of xxx-xx-6789. i.e 123456789 should be displayed as xxx-xx-6789 in a textfield. The code I am using write now is

string SSN = "123456789";
Regex ssnRegex = new Regex("(?:[0-9]{3})(?:[0-9]{2})(?:[0-9]{4})");
string formattedSSN = ssnRegex.Replace(SSN, "XXX-XX-${last}");

What is correct Reg Expression to mask ssn xxx-xx-6789 ?

View 1 Replies

Web Forms :: Regex Formatting Raw Number To Currency Format?

Aug 16, 2010

I am trying to take user supplied raw numeric values (these numbers dont have decimal point) and correctly format the values to their correct currency display.


eg: user enters 2341 the routine would use regex to format it to 23.41

I cant find a way to do this. What I have tried is this:

[Code]....

It doesnt work.... sNjunk always comes out 299 instead of 2.99.Anyone out there that can help me with this? or point me in the right direction?

View 6 Replies

ADO.NET :: How To Format A TIME COLUMN In SQL 08 To Regular Time And Not Military Time

Mar 5, 2011

Anyone know how to format a TIME COLUMN in SQL 08 to regular time and not military time? VB.net

View 2 Replies

Web Forms :: RegEx For Csv Time Value?

Sep 7, 2010

My requirement is as follows:

I want a text box which will accept CSV values and the values can be any time of a day,i.e.,in one text box I can enter multiple clock times,separated by comma.Hour,Minutes will be separated by :.Second no required

If a.m. or p.m. can be associated it would be great[0-12 basis], otherwise 0-24 basis will be fine.

Accepted Inputs:1:00,12:45,23:59,11:34

View 7 Replies

Regex For Diffrent Date Time Formats?

Oct 6, 2010

Every date time format can be represented by a regular expression how can i get the a regular expression for a perticulat format?using .net API

View 3 Replies

Forms Data Controls :: C# - Create A 'Time" Column Which Shows The Elapsed Time In HH:MM Format?

Mar 18, 2010

I have 2 fields being displayed in a Gridview, StartTime, EndTime. I want to create a 'Time" column which shows the elapsed time in HH:MM format. (StartTime - EndTime) This was all generated with VS2008, table is pulled from an SQL Query.

View 1 Replies

Trying To Format Time To This 10:00 AM?

Sep 9, 2010

Im trying to format time to this 10:00 AM. I tried:

Eval("doma","{0:d}")Eval("doma", "{0:HH:mm}") Eval("doma", "{HH:mm}")Eval("doma", "{0:HH:mm tt}")

But it tells me:Exception Details: System.FormatException: Input string was not in a correct format.I think the problem might be that I'm use TIME form in SQL 2008 and maybe its expecting a long date/time format, maybe? But in any case it still should format at time, right?

View 7 Replies

Format For Time Only In Sql?

Sep 28, 2010

is there a format for time only in mysql

View 2 Replies

Using RegEx With LINQ - Insert A Value Into The Regex?

Feb 19, 2010

I'm having a little trouble with using regex in linq. I want to be able to perform a search on values in my database. The goal is to insert a value into the regex and then use that to search a column in a table in my database for that term. I want it to work so that it gets all exact matches and also returns matches in which the search term is a substring of the term in the column.

I was trying to follow this tutorial on msdn, but it doesn't quite fit perfectly with my problem:

[URL]

Code:

[code]....

View 11 Replies

Format Datetime With Or Without The Time

Jan 3, 2010

Sometimes I get a datetime with a time sometimes it's just the date. Of course if it's just the date I I want to format with "dd.MM.yyyy" and if it has a time "dd.MM.yyyy HH:mm".. This is in a repeater, so I thought may be it's possible without a simple if statement?

View 3 Replies

Populate The Ddl With Time In Hh:mm Format?

Jan 30, 2010

I want to have a dropdownlist control for selecting time in hh:mm format. I'm not sure how to achieve this. I do not want any third party controls.

I want to populate the ddl with time in hh:mm format.

View 2 Replies

Convert Specified Format Of Time To A Date?

Jan 12, 2010

I have time, for e.g 33 hr 40 mins 50 secs . i would like to convert it to a date time format.

for e.g I have used Convert.ToDateTime("33:40:50"), but in this case when you converting to date time, hour should be less than 24, otherwise it will fire an exception.

View 1 Replies

How To Convert Time Format From M/dd/yy To Dd-MMM-yyyy With Vb.net

Mar 19, 2011

I have a literal on my webform. It displays date from a database as 3/26/2011 but I want it to display the date as 26-Mar-2011

How do I do this with VB.NET?

View 2 Replies

Displaying Data Into Time Format

Jan 24, 2011

I have time data coming from database as '081500' for 8.15 am. Now, in the asp.net display, i need to format it as 08:00. I do not need the millisecond. I tried by using DataFormatString

View 2 Replies

Web Forms :: How To Display Time Format

May 25, 2010

I am having following value, I want to display only time value in 24 hours format,let me know how can I do this?

DateTime StartDate = DateTime.Parse(item["Start Date"].ToString());

View 4 Replies

Web Forms :: Time Format Is Required

Sep 1, 2010

In my application i need the time format the text box should accept as hour as 0 to 24,minute as 0 to 60 and second as 0 to 60.so when i will give hh:mm:ss then it will take 0 to 24:0 to 60:0 to 60 only not more then that.

View 6 Replies

Web Forms :: Save Time In Am / Pm Format?

Mar 24, 2012

i want  the time input save in  hh:mm:ss am/pm this format otherwise it gives error how can i do via validation?

View 1 Replies

C# - Calculation Of Total Seconds From A Particular Format Of Time?

Jan 12, 2010

How to calculate total seconds of '33 hr 40 mins 40 secs' in asp.net c#

View 4 Replies

Validate The Test Field Which Contain Time Format

Nov 22, 2010

I am try to validate the the test box. In which user type time like 8.00 or 9.00. For validation i am using.

[Code]....

View 8 Replies

Convert Database Field To Time Format

Oct 5, 2010

I'm trying to make my string a nice formatted time but the column in the database isn't set up as a date/time field is there anyway I can do this? Here's my query

Dim query as String = "Select * from openquery (devbook, 'SELECT wb.arrival_time FROM web_bookings wb ')"

And here's where i'm converting it

Session("formattime") = DateTime.Parse(drv.Row("arrival_time")).ToString("hh:mm")

The arrival_time field only has 4 numbers in like this 1000 so I need a way of converting it to a nice format like this 10:00AM

View 5 Replies

DataSource Controls :: How To Convert The Time Format

May 10, 2010

i create a stored procedure that would out the following time format

09 hr(s): 30 min(s)

but i want to convert it to a decimal. (eg 9.50)

I was trying this method:

ALTER procedure [dbo].[timetodecimal] @hms varchar(8)

View 7 Replies

Web Forms :: Converting Date And Time Format In Vb.net?

Apr 22, 2010

I have searched a few pages on this (including MSDN) but have not quite reached a solution. I need to convert "16/04/2010 22:39:06" to "2010-04-16 22:39:06.034" (for example).

I have already written an SQL function to do this, but would rather do this in VB.NET if possible. The date value is coming from the Date Created information of a newly uploaded file:

[Code]....

View 3 Replies

Date Time Format Problem In Sql Server?

Jan 30, 2010

I have an application in asp.net which worked fine untill recently when i changed the datetime format in Regional and Language Settings in Control Panel.The date time format was default when i installed XP. I chose Indian standard time while installing XP.I changed the date time format to dd/MM/yyyy HH:mm:ss. And my application started to throw an exception whenever i tried to insert any datetime in to the table.The exception i get is:System.Data.SqlClient.SqlException: Error converting data type varchar to datetime.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved