Click here to Skip to main content
15,668,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Complication error is being thrown on below statements in my vbscript file

Dim dtsnow, currentDate, startDate
Dim dd, mm, yy

'Store DateTimeStamp once
set dtsnow = Now()

'Individual date components
set dd = Right("00" & Day(dtsnow), 2)
set mm = Right("00" & Month(dtsnow), 2)
set yy = Year(dtsnow)

'Build the date string in the format yyyy-mm-dd
set currentDate = yy & mm& dd
set startDate = yy& mm & "01"

I am just trying to take start date of current month and current date in this format "yyyymmdd".... 20200701 and 20200724

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = startDate
session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").selectionInterval = startDate,startDate

What I have tried:

Not able to resolve this error
Updated 3-Dec-21 5:06am
Patrice T 24-Jul-20 12:08pm    
Exact error message please.
show the line of error too.
Member 14636607 24-Jul-20 12:16pm    
i think the error is in this statement

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = startDate
Patrice T 24-Jul-20 12:36pm    
Don't guess !
The error message includes the line number of error in code.
Member 14636607 24-Jul-20 12:42pm    
this line only

session.findById("wnd[1]/usr/cntlCONTAINER/shellcont/shell").focusDate = startDate
Patrice T 24-Jul-20 12:43pm    
Use Improve question to update your question.
So that everyone can pay attention to this information.
By the way, for this message, error can come from previous lines.

1 solution

There would be better ways to write it, though for now, correction/changes to what you wrote that would work:
public class compiler
  shared function Main as integer
    ' Here your code !
    Dim dtsnow As date
    Dim currentDate, startDate As String
    Dim dd, mm, yy As String
    'Store DateTimeStamp once
    dtsnow = Now()
    'Individual date components
    dd = Right("00" & Day(dtsnow), 2)
    mm = Right("00" & Month(dtsnow), 2)
    yy = Year(dtsnow)
    'Build the date string in the format yyyy-mm-dd
    currentDate = yy + mm + dd
    startDate = yy + mm + "01"

    Console.WriteLine ("currentDate:"+currentDate)
    Console.WriteLine ("startDate:"+startDate)

    return 0
  End function
end class
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900