Jump to content
Sign in to follow this  
d0n

Date annoyance

Recommended Posts

d0n

So here is the problem, i have a date 01-01 (Jan 1st)

i want to add 7 days to it = 01-08 (Jan 8th)

However i am running into problems with the month of feburary 28/29 days.

what would be the best ways to do this?

$Date = '!09-30'

$Date = StringTrimLeft($Date, 1)
If StringRight($Date, 2)+7 > 31 Then
    If StringLeft($Date, 2) > 9 Then 
        $Date = "!"&StringLeft($Date, 2)
    Else
        $Date = "!0"&StringLeft($Date, 2)
    EndIf
    $Date = $Date & "-0"& (StringRight($Date, 2)+7)-31
Else
    if StringLen(StringRight($Date, 2)+7) < 2 Then
        $Date = "!"&StringLeft($Date, 2) &"-0"& StringRight($Date, 2)+7
    Else
        $Date = "!"&StringLeft($Date, 2) &"-"& StringRight($Date, 2)+7
    EndIf
EndIf

MsgBox("","",$Date)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.