Date Formatting Issue
Hello Im developing a report that is using SSRS 2005 as the reporting software and Oracle as the database. The report contains a calendar control so that users can select a date range. (DateStart & DateEnd) However, the column that the report is querying against is not formatted as a date, but rather it is a number. (E.g. 12/10/2007 is 20071205 in the table) Ive set up the report parameters with a data type of DateTime and then in the DataSet properties Im using the following values: DateStart =RIGHT(Parameters!DateStart.Value, 4) & LEFT(Parameters!DateStart.Value, 2) & MID(Parameters!DateStart.Value, 4,2) DateEnd =RIGHT(Parameters!DateEnd.Value, 4) & LEFT(Parameters!DateEnd.Value, 2) & MID(Parameters!DateEnd.Value,4,2) Then, Im using the TO_NUMBER function in the SQL pane around each parameter. The problem is, the calendar control is only sending a 1 byte number when the month and/or day is not 2 bytes. (E.g. 07/06/2007 is 7/6/2007, but I need to convert it to 20070706) Does anyone have any suggestions for how to resolve this issue? Thank you Helen
December 10th, 2007 10:18pm

Ok. As the date that returns the control couldnt of the same length (could be 7/12/2007 or 22/1/2008) you have to cut the string looking for the slash positions. Then the easier way to format is first add one or two zeros and then cut from the right each string. I.e. in the first date the strings would be from 7/12/2007 to 7, 12 , 2007 then 007, 0012 , 2007 and finally 20071207 FormatedDateEnd = Right(Parameters!DateEnd.Value,4) & Right(00 & Left(Parameters!DateEnd.Value,instr(instr(Parameters!DateEnd.Value,/), Parameters!DateEnd.Value,/) ) , Length(Parameters!DateEnd.Value) - instr(instr(Parameters!DateEnd.Value,/), Parameters!DateEnd.Value,/)) & Right(00 & Left(Parameters!DateEnd.Value,instr(Parameters!DateEnd.Value,/) ) , Length(Parameters!DateEnd.Value) - instr(Parameters!DateEnd.Value,/))
Free Windows Admin Tool Kit Click here and download it now
December 11th, 2007 12:54am

Thank you very much! I couldn't get your version to work, but Imodfied it and it now works. Here's what I did! =Right(Parameters!DateEnd.value, 4) & IIf(InStr(1, Parameters!DateEnd.value, "/") = 3, Left(Parameters!DateEnd.value, 2), "0" & Left(Parameters!DateEnd.value, 1)) & IIf(Len(Mid(Parameters!DateEnd.value, InStr(1, Parameters!DateEnd.value, "/") + 1, InStr(InStr(1, Parameters!DateEnd.value, "/") + 1, Parameters!DateEnd.value, "/") - (InStr(1, Parameters!DateEnd.value, "/") + 1))) = 1, "0" & Mid(Parameters!DateEnd.value, InStr(1, Parameters!DateEnd.value, "/") + 1, InStr(InStr(1, Parameters!DateEnd.value, "/") + 1, Parameters!DateEnd.value, "/") - (InStr(1, Parameters!DateEnd.value, "/") + 1)), Mid(Parameters!DateEnd.value, InStr(1, Parameters!DateEnd.value, "/") + 1, InStr(InStr(1, Parameters!DateEnd.value, "/") + 1, Parameters!DateEnd.value, "/") - (InStr(1, Parameters!DateEnd.value, "/") + 1)))
December 11th, 2007 9:54pm

I am having the same problem too and I am not so familiar with how to use SSRS2005 as the <a href="http://www.reportingsoftware.info">reporting software</a> and thanks for sharing the format of date!
Free Windows Admin Tool Kit Click here and download it now
January 27th, 2011 6:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics