Groups | Blog | Home
all groups > sql server reporting services > december 2004 >

sql server reporting services : Input String Was Not in Correct Format with Dates


Hunter Hillegas
12/15/2004 2:15:01 PM
I am passing dates to a function (below) and sending the output to a text
field. I am getting an error 'Input String Was Not in Correct Format with
Dates' when I run the report.

I have tried the following expressions for the text field, with the same
results:

=Code.determineTimePeriod("01/01/1900", "01/01/1900")
=Code.determineTimePeriod(cdate("01/01/1900") ,cdate("01/01/1900") )

Eventually I want to pass in SQL datetime attributes from a dataset, but I
wanted to get it working with straight up strings first.

Function determineTimePeriod(ByVal currentDate As Date, ByVal rowDate As
Date) As String

Dim currentYear As Integer
Dim currentMonth As Integer
Dim currentDay As Integer
Dim startOfCurrentPeriod As Date
Dim monthOffset As Long

currentYear = DatePart(DateInterval.Year, currentDate)
currentMonth = DatePart(DateInterval.Month, currentDate)
currentDay = DatePart(DateInterval.Day, currentDate)
startOfCurrentPeriod = DateValue(currentMonth + "/" + "01" +
currentYear)

If (rowDate <> Nothing) Then
monthOffset = DateDiff(DateInterval.Month, startOfCurrentPeriod,
rowDate)

If (monthOffset <= -1) Then
Return "Prior"
ElseIf (monthOffset > 0 And monthOffset < 1) Then
Return "Current"
ElseIf (monthOffset > 1 And monthOffset < 2) Then
Return "Next"
ElseIf (monthOffset > 2) Then
Return "Future"
End If
Else
Return "TBR"
End If
Chans
12/16/2004 1:33:04 AM
Problem will be only with the DateValue format.
Try with this format MyDate = DateValue("February 12, 1969").


[quoted text, click to view]
Hunter Hillegas
12/16/2004 9:19:06 AM
In the function? Looking at the docs for DateValue(), it should support the
format I am trying to use: "2/12/69".

Are you saying the function is wrong or the inputs? The function needs to
create a date that is at the start of the current month (as it does) and then
use that for processing.


[quoted text, click to view]
Chans
12/16/2004 9:39:01 PM
Its only bcos of input value. The input string formed should be similar to
the one u have given below. change the month and year value to string and
then concat. It will work.

something similar to this...
startOfCurrentPeriod = DateValue(CStr(currentMonth) + "/01/" +
CStr(currentYear))


[quoted text, click to view]
AddThis Social Bookmark Button