|
-
Jan 25th, 2007, 10:23 AM
#1
Thread Starter
Frenzied Member
Format and compare time
I have the time in the format of 11:25pm
Is there a quick function that can compare the string above, with the current time and check if its before now, now, or after now?
I can do it the long winded way by extracting the hours,mins etc and comparing but I was hoping there would be a function already.
Cheers
-
Jan 25th, 2007, 11:13 AM
#2
Re: Format and compare time
You can use DateTime.Compare method.
.Compare returns an integer value: -1 for less than, 0 for equal, and 1 for greater than if you just want a quick check rather than specific amounts of minutes or hours.
Last edited by stimbo; Jan 25th, 2007 at 11:30 AM.
-
Jan 25th, 2007, 11:16 AM
#3
Re: Format and compare time
Scroll down to Post #14 in this thread.
-
Jan 25th, 2007, 11:21 AM
#4
Re: Format and compare time
There could be an issue is 11:27 pm before or after your time? What if that time (11:27 pm) was last night of 3 days ago was that before the current time?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jan 25th, 2007, 01:35 PM
#5
Thread Starter
Frenzied Member
Re: Format and compare time
the day doesnt matter, I only want to know if the current time is prior, equal, or beyond the input string in the format of "1.35pm" or "10.50am". I'll try the suggesstions and wirte back,
Cheers
-
Jan 25th, 2007, 01:45 PM
#6
Thread Starter
Frenzied Member
Re: Format and compare time
thanks that compare function was just what I needed.
The second thing I need is a function to convert this time format:
11.50am or 3.05pm or 9.10am
to this:
11:50 or 15:05 or 9:10
Like i said it can be done by extracting the mins, hours, pm and am, but I was hoping there would be a function like Format() that could do it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|