Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 Convert VB Script to function in SQL Server Report

Author  Topic 

kdnichols
Posting Yak Master

232 Posts

Posted - 2006-11-09 : 09:48:30
Hello Everyone,

I do not see the forum for Reporting Services, so I will post this here for now. I have a VB Script that I would like to use as a Function to return the Weekday Name for me in Reporting Services.

[code]
Function rDateTime(rDate, rTime)

DIM myDay, myDayName, myMonthName , myYear, myTime
DIM myAMPM, myHour, myColon, myMinute

'get AM or PM from the time
myAMPM = Right(rTime,2)

'get Hour and Minute
myColon = instr(1, rTime, ":",vbBinaryCompare)

IF myColon = 2 THEN
myHour = Left(rTime,1)
myMinute = Mid(rTime, 3, 2)
ELSE
myHour = Left(rTime,2)
myMinute = Mid(rTime, 4, 2)
END IF

'concatenate the time
myTime = myHour & ":" & myMinute & " " & myAMPM

'get weekday number
myDayName = weekday(rDate)

'convert weekday number to weekday name
myDayName = weekdayname(myDayName)

'get the day, e.g. oct 19, 2002, will return 19
myDay = Day(rDate)

'get month number
myMonthName = Month(rDate)

'convert month number to month name (abbreviation True)
myMonthName = MonthName(myMonthName, True)

'get the year
myYear = Year(rDate)

'concatenate variables
rDateTime = myDayName & myMonthName & ". " & myDay & ", " & myYear & myTime"

End Function

How should I use this as a funciton in SQL Server Reporting Services? I think that I need to use a calculated field. Am I correct or what do I need to do to implment this. This code will return the Weekday Name which is what I need.

TIA for any help in advance.

Have a great day!



Kurt

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-09 : 11:53:01
"I do not see the forum for Reporting Services"
Yes there is. http://www.sqlteam.com/forums/forum.asp?FORUM_ID=21

This forum is for posting workable script. Please post in appropiate forum


KH

Go to Top of Page
   

- Advertisement -