×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Dim as date, with a few other questions?

Dim as date, with a few other questions?

Dim as date, with a few other questions?

(OP)
I am scraping some text from the screen that is in the format of 02/02/2012 and putting it into a variable
I am trying to delcare my variable as a date using dim dayyt as date. Attachmate does not seem to like this.
please can you tell me what I should be using?
I want to add 3 days to the date, how do I do that?
If by adding 3 days the date is a Saturday or a Sunday I want to add 2 or 1 days as requred.
How to I work out if a date is a sataurday or Sunday

thank you in advance
smiler44

RE: Dim as date, with a few other questions?

i have something like this

CODE

mydate = sess.getstring (2,63,8)
    
    mm = mid(mydate,1,2)
    dd = mid(mydate,4,2)
    yy = mid(mydate,7,2)
    
    
    tday = DateSerial(yy,mm,dd)
    daynumber = weekday(tday)

    select case daynumber
        case 1  : 'dosomething this is sunday
        case 2  : 'dosomething
        case 3  : 'dosomething
        case 4  : 'dosomething
        case 5  : 'dosomething
        case 6  : 'dosomething
        case 7  : 'dosomething this is saturday
    end select
    
    newdate = tday + 5
    
    msgbox newdate 

RE: Dim as date, with a few other questions?

(OP)
remy988,
My apologies for not replying, no excuse and unprofessional of me. I am sorry.
think i can follow it, but if i have understood yy = mid(mydate,7,2) should be yy = mid(mydate,9,2) for my use.
I have never understood select case but I think I can skip that and go to newdate = tday + 5 . i will have a practice
thank you
smiler44

RE: Dim as date, with a few other questions?

CODE

daynumber = weekday(tday) 

weekday returns a numeric value that corresponds to a day,
so 1 = sunday, 2= monday, 3 = tuesday...etc

so if tday is tuesday, the numeric value is 3.

assuming today is tuesday, if you use newdate = tday + 5, then you would get sunday as your date. if you don't want sunday, then you would need to use select case

CODE

select case daynumber
        case 1  : 'dosomething this is sunday
        case 2  : 'dosomething
        case 3  : newdate = tday + 6 '6 would give you monday
        case 4  : 'dosomething
        case 5  : 'dosomething
        case 6  : 'dosomething
        case 7  : 'dosomething this is saturday
    end select 

RE: Dim as date, with a few other questions?

(OP)
remmy998,
I'll give selcet case ago thank you for explaining it. I tried the rest of the code last night and will try it again in case i made a mistake. I may have used 28/02/12 instead of 28/02/13 but adding 5 days gave me the wrong date in march, starting with a date in january gave me the right date in February.

appreciate the help
smiler44

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close