I have to compare two dates. My source fields are varchar(10) columns.
e.g. in the format 2003-12-10
I order to compare I plan to change the format to YYYYMMDD format. How do I remove '-' in them?
Is it that after removing them I need to convert these varchar field to decimal using StringToDecimal function. So that I can use greater than or less than operations.
Comparing dates
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
I did not know that a direct compare will work. As craig suggested make sure the date and month fields are always 2 characters and do a direct compare. As it is for StringtoDate to work you will have to make sure that the length of the data is 10 characters. So
If len(input.date11) = 10 and len(input.date22) = 10 then compare logic else ().
You would have to take care of the else condition though if the lengths are not 10.
If len(input.date11) = 10 and len(input.date22) = 10 then compare logic else ().
You would have to take care of the else condition though if the lengths are not 10.
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad