Hi,
I have the following code :
Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String,
ByVal EdPeriod As String, ByVal TaskType As String) As Integer
Dim strtest As String
Dim i, j As Integer
i = strtest.Compare(EvDt,StPeriod)
Select Case (TaskType)
Case "Old"
If (i < 0) Then 'EvDt is before StPeriod
Return (1)
Else
Return (0)
End If
Case "New"
If (i >= 0) Then 'EvDt is after of equal to StPeriod
j = strtest.Compare(EvDt, EdPeriod)
If (j < 0) Then 'EvDt is before EndPeriod (so, between
StPeriod and EdPeriod
Return (1)
End If
Else
Return (0)
End If
End Select
End Function
unfortunately, it does not work well...
if EvDt < StPeriod, i >0...and it should be i<0....
for example :
EvDt = 02.01.2005
StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot,
Maileen 6 2108
If EvDt = "02.01.2005" and StPeriod = "01.06.2005", then EvDt is greather
then StPeriod. And so 'i' ends up being greater then 0.
So what's the problem? Or am I not understanding something?
"Maileen" <no*****@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl... Hi,
I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim i, j As Integer i = strtest.Compare(EvDt,StPeriod) Select Case (TaskType) Case "Old" If (i < 0) Then 'EvDt is before StPeriod Return (1) Else Return (0) End If Case "New" If (i >= 0) Then 'EvDt is after of equal to StPeriod j = strtest.Compare(EvDt, EdPeriod) If (j < 0) Then 'EvDt is before EndPeriod (so, between StPeriod and EdPeriod Return (1) End If Else Return (0) End If End Select
End Function
unfortunately, it does not work well... if EvDt < StPeriod, i >0...and it should be i<0.... for example :
EvDt = 02.01.2005 StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot, Maileen
Hi Marina,
sorry but where i live January 02nd is before 1st june ;-)
so, string compare is it based on highest first characters found in string ?
in this case, how to compare date ?
because i will convert using CDate(EvDt) and CDate(StPeriod)
Maileen
Marina wrote: If EvDt = "02.01.2005" and StPeriod = "01.06.2005", then EvDt is greather then StPeriod. And so 'i' ends up being greater then 0.
So what's the problem? Or am I not understanding something?
"Maileen" <no*****@nospam.com> wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl...
Hi,
I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim i, j As Integer i = strtest.Compare(EvDt,StPeriod) Select Case (TaskType) Case "Old" If (i < 0) Then 'EvDt is before StPeriod Return (1) Else Return (0) End If Case "New" If (i >= 0) Then 'EvDt is after of equal to StPeriod j = strtest.Compare(EvDt, EdPeriod) If (j < 0) Then 'EvDt is before EndPeriod (so, between StPeriod and EdPeriod Return (1) End If Else Return (0) End If End Select
End Function
unfortunately, it does not work well... if EvDt < StPeriod, i >0...and it should be i<0.... for example :
EvDt = 02.01.2005 StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot, Maileen
Ok, well, I where live, the date format is month/day/year.
In any case, our preferred date formats are irrelevant. We are talking about
how string comparisons are done. And they are done the same way regardless
of what kind of meaning they have to you. And the fact is, "02.01.2005" is a
greater string then "01.06.2005".
This is just as the the string "10" will be considered less then the string
"2".
If you need date comparisons, you should use DateTime objects.
"Maileen" <no*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... Hi Marina,
sorry but where i live January 02nd is before 1st june ;-) so, string compare is it based on highest first characters found in string ?
in this case, how to compare date ? because i will convert using CDate(EvDt) and CDate(StPeriod)
Maileen
Marina wrote: If EvDt = "02.01.2005" and StPeriod = "01.06.2005", then EvDt is greather then StPeriod. And so 'i' ends up being greater then 0.
So what's the problem? Or am I not understanding something?
"Maileen" <no*****@nospam.com> wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl...
Hi,
I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim i, j As Integer i = strtest.Compare(EvDt,StPeriod) Select Case (TaskType) Case "Old" If (i < 0) Then 'EvDt is before StPeriod Return (1) Else Return (0) End If Case "New" If (i >= 0) Then 'EvDt is after of equal to StPeriod j = strtest.Compare(EvDt, EdPeriod) If (j < 0) Then 'EvDt is before EndPeriod (so, between StPeriod and EdPeriod Return (1) End If Else Return (0) End If End Select
End Function
unfortunately, it does not work well... if EvDt < StPeriod, i >0...and it should be i<0.... for example :
EvDt = 02.01.2005 StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot, Maileen
Maileen wrote: Hi,
I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim i, j As Integer i = strtest.Compare(EvDt,StPeriod) Select Case (TaskType) Case "Old" If (i < 0) Then 'EvDt is before StPeriod Return (1) Else Return (0) End If Case "New" If (i >= 0) Then 'EvDt is after of equal to StPeriod j = strtest.Compare(EvDt, EdPeriod) If (j < 0) Then 'EvDt is before EndPeriod (so, between StPeriod and EdPeriod Return (1) End If Else Return (0) End If End Select
End Function
unfortunately, it does not work well... if EvDt < StPeriod, i >0...and it should be i<0.... for example :
EvDt = 02.01.2005 StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot, Maileen
Why are you not converting these to dates and then comparing them?
Chris
thanks Marina,
i was already exploring this DateTime type for my solution.
thanks for help.
maileen
Marina wrote: Ok, well, I where live, the date format is month/day/year.
In any case, our preferred date formats are irrelevant. We are talking about how string comparisons are done. And they are done the same way regardless of what kind of meaning they have to you. And the fact is, "02.01.2005" is a greater string then "01.06.2005".
This is just as the the string "10" will be considered less then the string "2".
If you need date comparisons, you should use DateTime objects.
"Maileen" <no*****@nospam.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi Marina,
sorry but where i live January 02nd is before 1st june ;-) so, string compare is it based on highest first characters found in string ?
in this case, how to compare date ? because i will convert using CDate(EvDt) and CDate(StPeriod)
Maileen
Marina wrote:
If EvDt = "02.01.2005" and StPeriod = "01.06.2005", then EvDt is greather then StPeriod. And so 'i' ends up being greater then 0.
So what's the problem? Or am I not understanding something?
"Maileen" <no*****@nospam.com> wrote in message news:%2******************@TK2MSFTNGP14.phx.gbl. ..
Hi,
I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim i, j As Integer i = strtest.Compare(EvDt,StPeriod) Select Case (TaskType) Case "Old" If (i < 0) Then 'EvDt is before StPeriod Return (1) Else Return (0) End If Case "New" If (i >= 0) Then 'EvDt is after of equal to StPeriod j = strtest.Compare(EvDt, EdPeriod) If (j < 0) Then 'EvDt is before EndPeriod (so, between StPeriod and EdPeriod Return (1) End If Else Return (0) End If End Select
End Function
unfortunately, it does not work well... if EvDt < StPeriod, i >0...and it should be i<0.... for example :
EvDt = 02.01.2005 StPeriod = 01.06.2005
thus i >0, how is it possible ?
thanks a lot, Maileen
Maileen,
In addition to the others
In almost every (non Coca Cola culture) dates are almost impossible to
compare by non humans.
Therefore is the ISO date written as Year, Month, Day, Hours, Minutes,
Seconds
The datetime in Net is in ticks as the number of 100-nanosecond intervals
that have elapsed since 12:00 A.M., January 1, 0001 using the Georgian
Calendar.
To compare dates behind that starting Georgian Calendar date is in my
opinion the datetime.ticks the most easy one.
I hope this helps,
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: usgog |
last post by:
I need to implement a function to return True/false whether String A
contains String B. For example, String A = "This is a test"; String B =
"is is". So it will return TRUE if String A includes two...
|
by: Wolfgang Draxinger |
last post by:
I understand that it is perfectly possible to store UTF-8 strings
in a std::string, however doing so can cause some implicaions.
E.g. you can't count the amount of characters by length() |
size()....
|
by: David zhu |
last post by:
I've got different result when comparing two strings
using "==" and string.Compare().
The two strings seems to have same value "1202002" in
the quick watch, and both have the same length 7 which I...
|
by: lchian |
last post by:
Hi,
For two stl strings s1 and s2, I got different results from
strcmp(s1.c_str(), s2.c_str())
and
s1.compare(s2)
can someone explain what these functions do? It seems that strcmp
gives...
|
by: Mosfet |
last post by:
Hi,
what is the most efficient way of doing a case insensitive comparison ?
I am trying to write a universal String class and I am stuck with the
case insensitive part :
TCHAR is a char in...
|
by: Tony |
last post by:
Hello!
Below I have two different ways to test if the instance tb.Text contains the
string "Programmer"
So which one to use is it just a matter of taste ?
Or could it be some advantage to one...
|
by: blunt |
last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
|
by: blunt |
last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
|
by: erictheone |
last post by:
so here is my code. My getlines for the strings keyword and phrase at lines 44 and 79 respectively don't work. Please help!!!
#include <cstdlib>
#include <string>
#include <iostream>
#include...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |