Sign in to follow this  
Followers 0
BreCalmor

Comparing date with a list of dates

4 posts in this topic

What is the best way to compare a date "11/14/08" with a list of dates. Maybe from an INI file.

I created a function and manually use a select with strings... Not exactly pretty, and has to be edited every few days.

Func _CheckDate ($sChkDate)
    Select
        Case $sChkDate = "11/17/2008"
            Return False
        Case $sChkDate = "11/20/2008"
            Return False
        Case Else
            Return True
            
    EndSelect
EndFunc

Just having a brain fart and hoping someone can help an old man out.

Thanks,

Bre

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What is the best way to compare a date "11/14/08" with a list of dates. Maybe from an INI file.

I created a function and manually use a select with strings... Not exactly pretty, and has to be edited every few days.

Func _CheckDate ($sChkDate)
    Select
        Case $sChkDate = "11/17/2008"
            Return False
        Case $sChkDate = "11/20/2008"
            Return False
        Case Else
            Return True
            
    EndSelect
EndFunc

Just having a brain fart and hoping someone can help an old man out.

Thanks,

Bre

Well, to start with, you have to pick a format. You show two different ones here (two and four digit years).

Best for AutoIt would be "YYYY/MM/DD[ HH:MM:SS]". The time portion is in a square bracket because it is optional. This format works with functions like _DateDiff() and _DateAdd(). But if all you need is a string compare then it doesn't matter if you use that one.

Why do you have to edit it every few days? Seems likely the script could figure out the dates required and work with them on its own. Is it always "next Monday" and "next Tuesday" for example? That can be calculated on the fly each time the script is run.

:mellow:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Well, to start with, you have to pick a format. You show two different ones here (two and four digit years).

Best for AutoIt would be "YYYY/MM/DD[ HH:MM:SS]". The time portion is in a square bracket because it is optional. This format works with functions like _DateDiff() and _DateAdd(). But if all you need is a string compare then it doesn't matter if you use that one.

Why do you have to edit it every few days? Seems likely the script could figure out the dates required and work with them on its own. Is it always "next Monday" and "next Tuesday" for example? That can be calculated on the fly each time the script is run.

:mellow:

The dates will have the YYYY format, I just mistyped. The main reason it needs to be edited is because I need to read data from 2 different websites and as of right now, it is a manual process. I haven't figured out the logic to do it automatically yet.

I think I will stick with the existing functionality, but move to an INI read for the dates. Once I figure out the logic, that will remove the need for this function.

I just wasn't sure if the select was the best way to compare a date, but since I am using strings, it probably is.

Thanks for your comments.

Share this post


Link to post
Share on other sites

The dates will have the YYYY format, I just mistyped. The main reason it needs to be edited is because I need to read data from 2 different websites and as of right now, it is a manual process. I haven't figured out the logic to do it automatically yet.

I think I will stick with the existing functionality, but move to an INI read for the dates. Once I figure out the logic, that will remove the need for this function.

I just wasn't sure if the select was the best way to compare a date, but since I am using strings, it probably is.

Thanks for your comments.

Do you mean the dates come from a web page? Have you looked at the _IE* functions and considered pulling them by the script?

:mellow:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0