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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Convert VB Script to function in SQL Server Report
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

232 Posts

Posted - 11/09/2006 :  09:48:30  Show Profile  Send kdnichols an AOL message  Reply with Quote
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.

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)
myHour = Left(rTime,2)
myMinute = Mid(rTime, 4, 2)

'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!


In (Som, Ni, Yak)

17689 Posts

Posted - 11/09/2006 :  11:53:01  Show Profile  Reply with Quote
"I do not see the forum for Reporting Services"
Yes there is.

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


Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000