cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Current Date As End Date In SQL Pramaeters

former_member202170
Active Participant
0 Kudos

Hi All

I am using stored procedure in Crystal reports it has start date and end date

with out  using sub report how can i pass end date as current date  in SQL Command line

in Crystal reports

Please Advise

Thanks

Krishna M

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Krishna,

You could try calling the SP using a Command Object:

E.g command for Oracle:

Exec Procedure_Name to_date({?Start_Date}), sysdate


{?Start_Date} is a prompt that is created in the Command window.


-Abhilash

former_member202170
Active Participant
0 Kudos

i tried it abhlash but no luck

thanks  buddy

Thanks

Krishna M

abhilash_kumar
Active Contributor
0 Kudos

Could you tell us know what happens? Does CR throw an error?

-Abhilash

former_member202170
Active Participant
0 Kudos

when the ran the same stored procedure in SQL server it is throwing error

abhilash

Thanks

Krishna M

abhilash_kumar
Active Contributor
0 Kudos

What is the error?

Please paste the command you've used here.

-Abhilash

former_member202170
Active Participant
0 Kudos

Exec [dbo].[cr_projects] 'IND','01/01/2015',currentdate

Msg 8114, Level 16, State 1, Procedure [dbo].[cr_project], Line 0

Error converting data type nvarchar to date.

when i run the command in sql server it is throwing an error

Please advise

Thanks

Krishna M

abhilash_kumar
Active Contributor
0 Kudos

Try:

Exec [dbo].[cr_projects] 'IND','01/01/2015', getdate()


-Abhilash

former_member202170
Active Participant
0 Kudos

Exec [dbo].[cr_projects] 'IND','01/01/2015',getdate()

yes abhilash thanks for the support but it is throwing an Error again

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near ')'.

Please Advise

Thanks

Krishna M

former_member202170
Active Participant
0 Kudos

Hey Thanks abhilash with you support only it is possible  did some small modifications to the stored procedure

found the solution

DECLARE @GetDateValue datetime;

SET @GetDateValue = GetDate();

Exec [dbo].[cr_projects] 'IND','01/01/2015', @WeekEndDate = @GetDateValue;

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Kudos

Instead of calling the stored proc as a data source, create a command that will call the stored proc.  You can then use the database syntax to pass the current date as the end date parameter.

For more information about using commands, see my blog post here:  .

-Dell