Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date format for SQL server data

Hi,

I am reading in data from a SQL server and I the one field is in the format yyyy.dd.mm. How can I format this in QV into a date format with the format yyyy/mm/dd? Then function Date(Datevariable, 'YYYY/MM/DD') As Date does not seem to work in SQL syntax.

It will be brilliant if anyone can help me!

6 Replies
deepakk
Partner - Specialist III
Partner - Specialist III

Hi,

Use Load statement before the sql and then use the Date function.

eg:

Load

Date(Date,'YYYY/MM/DD') as Date;

select Date from Table;

Not applicable
Author

Thanks Deepak but do I understand you correctly that after the Connect to the sql server code I must insert the load statement and then in the select statement I must select the date?

Not applicable
Author

Hi,

Ya, You have understood properly.

Your Code Should be as follows.

//QV Load Statement, Here you are converting the SQL date in to proper Date using "Date()"

Load Field1,

Field2,

Date(Date_Field,'YYYY/MM/DD') as Date;

//SQL server Select Statement, Here you are Taking the data from SQL Server.

Select Field1,

Field2,

Date

From Table;

Note: Your "Load" stateme should be above "SQL" Statement.

Hope this helps you.

- Sridhar

Not applicable
Author

Thanks guys that sorted the problem!

Not applicable
Author

if you need to then filter by that date how do you do it  i.e.  SQL Select * where Date >= '08/25/2011' ?  I cannot get this to work

Not applicable
Author

Hi,

Use the below script:

 

Table1:

LOAD Field1,

Field2,

Date(Date_Field,'YYYY/MM/DD') as Date;

SQL SELECT

Field1, 

Field2,

Date(Date_Field,'YYYY/MM/DD') as Date;

FROM Table;

Regards,

Snehal Nabar