+ Reply to Thread
Results 1 to 4 of 4

Short date increment in VB

  1. #1
    Registered User
    Join Date
    03-20-2008
    Posts
    3

    Question Short date increment in VB

    Hi All,

    In my excel sheet I've the follwoing cells(see attached screenshot):
    Start Date 150308
    End Date 210308


    In my VB script I want to increment the date 150308 (which is the 15th of March 2008) one by one until 210308(which is the 21st of March 2008).
    Actually these dates are strings in my sheet.

    I need to convert them to date, after increment by one, and after convert back to string.

    Pls your help
    beforehand thanks
    Attached Images Attached Images

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why would you store dates as strings. Use a Custom Format, ddmmyy, & the task would be much simpler.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-20-2008
    Posts
    3
    Dear Roy,

    Thanks for your reply,

    In this case recommend me, how to write in this cell the 150308 as date, when I'm writing 150308, it is automatically converting to 7/12/2311.

    Thank you

  4. #4
    Registered User
    Join Date
    03-20-2008
    Posts
    3

    Cool Done

    Quote Originally Posted by royUK
    Why would you store dates as strings. Use a Custom Format, ddmmyy, & the task would be much simpler.
    Dear Roy,

    Pls see the code which I managed to write:

    Cdat = CStr(Cells(1, 4))
    TempDat = Mid(Cdat, 3, 2) + "/" + Mid(Cdat, 1, 2) + "/20" + Mid(Cdat, 5, 2)
    Dt = CDate(TempDat)
    Dt = Dt + 1
    Cdat = Format(Dt, "ddmmyy")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1