Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

cast varchar to date

Hi! All

I'm new to Qlikview..

I have a input box which takes a date.. so i'm trying to pass that value to a stored procedure

SET vID=cast('$(vID)' as int);
SET vStartDate=cast ('$(vStartDate)' as datetime);
SET vEndDate=cast('$(vEndDate)' as datetime);

SQL EXEC rpt_Machine_Details '$(vID)','$(vStartDate)', '$(vEndDate)'

I get an error that says Cast is not a valid function .

Is there a way to get a calender object just like in SSRS?

9 Replies
spsrk_84
Creator III
Creator III

Hi,

Did you tried to pass the parameters directly,check that if that works then use the variables and pass the parameters..

Regards,

Ajay

martin59
Specialist II
Specialist II

Hello,

What do you want to do ?

You have 2 dates (Begin + End) and you want to generate a Calendar table ?

You can only use your SQL functions into the QlikView's SQL instruction (SQL SELECT, SQL SET...)

Is it help you ?

Martin

Not applicable
Author

Hi Thanks for the reply..

When I pass the parameters directly it works perfect.. The problem come when I enter the date on the input box because it interpretes the data as varchar "2009-01-01"

So i'm trying to Cast that to date.

Is there a way I can choose the dates from a calendar instead of typing it in ?

@Martin

I don't want to generate a calendar table i just want to be able to select a date from a calendar and what ever date i select has to be assigned to (Begin or End date) variables from there i want to pass those variables to a stored procedure as parameters.

thanks.

martin59
Specialist II
Specialist II

You can use the calendar object to select a date which in a field, and obtain this value with the function "Only(FieldDate)".

Otherwise, you can use the input box and transform your varchar into a date format with the function "date#('2009-01-01','YYYY-MM-DD')"

Is it what you want ?

Not applicable
Author

@Martin

Thanks its working perfect.

Is there any calendar object besides the calendar Slider which i can use to select the dates..?

martin59
Specialist II
Specialist II

You can use the calendar object, with "Calendar" as input style.

You also can divide you date into 3 fields (Year, Month, Day) and show the list box.

Martin

Not applicable
Author

Thanks a lot Martin that's what I wanted to do using the calendar object

Thanks a million

Not applicable
Author

Marthin, how come I can only see 1900 as the year and Jan or Dec on month when i'm using Calendar as input style

martin59
Specialist II
Specialist II

Certainly because your date is not in the right format. You can use the date#() function in your load script.