Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Get First and Last day of month and Insert into Access table

$
0
0

I am currently moving over an SSIS package that was triggered by a VBScript, the package was orignially on a 32 biit machine and is now on a 64 so the VBScript does not work. The main function of the script is to insert the first and last day of the previous month into an access table. Those dates are then used later in the package. I am looking for a way to do this either through SSIS or any other function, I have tried execute SQL task and that has not seemed to work (in my other post), I have also tried to convert the script to ActiveX, run it through a data flow and execute process task to run the original 32 bit script.

I have pasted the script below, Any suggestions on how to run the script or insert the dates into the access table are welcome. Thank you!

'#################################################
'ZierdMONTHLY version
'#################################################

Dim varPath

'#####SET SSIS PACKAGE PATH#####
varPath = "C:\Package.dtsx"
'###############################
'#############################
IsThisMonthOrWeek = "M"
'#############################

'###CALL SUB###
PopulateMonthWeek
'###############

 Set WshShell = C:\Windows\SysWOW64\WScript.CreateObject("WScript.Shell")


ReturnCode = WshShell.Run("dtexec.exe /FILE """ & varPath & """ /DECRYPT apple MAXCONCURRENT "" -1 "" /CHECKPOINTING OFF  /REPORTING EWCDI  ")

 

 

 

 

'#########################################################################################

SUB PopulateMonthWeek
 set con = createobject("ADODB.Connection")
 dbPath = "C:\dealer.mdb"

 conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";User Id=admin;Password=;"

 con.open conString

 IF IsThisMonthOrWeek = "M" THEN
  con.execute "update tbl_startEndDates set weekOrMonth = '" & IsThisMonthOrWeek & "', startDate = '" & getFirstDayOfMonth & "', endDate = '" & getLastDayOfMonth & "'"
 ELSE
  con.execute "update tbl_startEndDates set weekOrMonth = '" & "W" & "', startDate = '" & Date() - WeekDay(Date())-6 & "', endDate = '" & Date() - WeekDay(Date()) & "'"
 END IF

 con.close

 set con=nothing
END SUB

 

FUNCTION getFirstDayOfMonth
 valMonth= month(now())-1
 valYear= Year(now())

 if valMonth = 1 then
  valMonth = 12
  valYear = valYear-1
 end if

 getFirstDayOfMonth = valMonth & "/1/" & valYear
END FUNCTION


FUNCTION getLastDayOfMonth
 valMonth= month(now())-1
 valYear= Year(now())

 if valMonth = 1 then
  valMonth = 12
  valYear = valYear-1
 end if

 din = valMonth & "/1/" & valYear

 getLastDayOfMonth = dateserial(year(din),month(din)+1,0)
END FUNCTION


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>