Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
khasimvali85
Creator II
Creator II

Date Conversion Problem

Hi Community,

Can any body solve this Error when i connect to data base Table showing error like

''ErrorSource: Microsoft OLE DB Provider for SQL Server, ErrorMsg: Conversion failed when converting date and/or time from character string.''

I Change Given format below

,Convert(Varchar,[Date_Field],103) as Date_Field   is it right?

Thanks in Advance

Regards,

Khasim.

20 Replies
ashfaq_haseeb
Champion III
Champion III

If SQL try below

Calls:

SELECT [Complaint_ID]

      ,Convert(Varchar,[complaint_date],103) as complaint_date

      ,[complaint_no]

      ,[count]

      ,Convert(datetime,[Reminder_Date],103) as Reminder_Date

      ,[NewAppointment]

      ,

crusader_
Partner - Specialist
Partner - Specialist

Hi,

Ashfaq suggested you right solution in the very first post.

Table:

LOAD

[Complaint_ID]

      ,date(floor([complaint_date])) as complaint_date

      ,[complaint_no]

      ,[count]

      ,date(floor([Reminder_Date])) as Reminder_Date

      ,[NewAppointment]

      ,[Comment]

;

SQL SELECT

      [Complaint_ID]

      ,[complaint_date]

      ,[complaint_no]

      ,[count]

      ,[Reminder_Date]

      ,[NewAppointment]

      ,

khasimvali85
Creator II
Creator II
Author

Hi Ashfaq,

     i am fetching from DataBase but why we are using Select Command?

In QVD fetching data shows Load Command right? previously with given conversion format its working fine and fetched data exact.

Regards,

Khasim.

rubenmarin

OK, It's solved now? If not, can you provide some sample date to see what conversion is needed?

If it helps, MSSQL convert statement is:

Syntax for CONVERT:

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

  expression

Is any valid expression.

  data_type 

Is the target data type. This includes xml, bigint, and sql_variant. Alias data types cannot be used.

  length 

Is an optional integer that specifies the length of the target data type. The default value is 30.

  style 

Is an integer expression that specifies how the CONVERT function is to translate expression. If style is NULL, NULL is returned. The range is determined by data_type. For more information, see the Remarks section.


(103 is dd/mm/yyyy format)

ashfaq_haseeb
Champion III
Champion III

Khasimvali Shaik wrote:

Hi Ashfaq,

My Script is

Calls:

SELECT [Complaint_ID]

      ,Convert(Varchar,[complaint_date],103) as complaint_date

      ,[complaint_no]

      ,[count]

      ,Convert(datetime,[Reminder_Date],103) as Reminder_Date

      ,[NewAppointment]

      ,[Comment]

From Calls;

Regards

Khasim.

Hi,

Check SQL part is missing here, you didn't provide complete script

try this and let me know

Calls:

SELECT [Complaint_ID]

      ,Convert(Varchar,[complaint_date],103) as complaint_date

      ,[complaint_no]

      ,[count]

      ,Convert(datetime,[Reminder_Date],103) as Reminder_Date

      ,[NewAppointment]

      ,

ashfaq_haseeb
Champion III
Champion III

Hi,

If it working previously

Try below SQL part was missing.

Calls:

SQL SELECT [Complaint_ID]

      ,Convert(Varchar,[complaint_date],103) as complaint_date

      ,[complaint_no]

      ,[count]

      ,Convert(datetime,[Reminder_Date],103) as Reminder_Date

      ,[NewAppointment]

      ,

maxgro
MVP
MVP

after some (a lot of) test

for me this works on a sql server database

when I remove the bold part I get an error

table:

sql select Convert(Varchar(10), dat_data, 103) as field1 from d003_date;

khasimvali85
Creator II
Creator II
Author

Hi Ashfaq,

                    without conversion format also working and also  SQL SELECT Statement also working.

but why when using  conversion(varchar,[dateField],103) as dateField not working.

showing same error.

ashfaq_haseeb
Champion III
Champion III

Try this now

Calls:

SELECT [Complaint_ID]

      ,date(floor([complaint_date])) as complaint_date

      ,[complaint_no]

      ,[count]

      date(floor([Reminder_Date])) as Reminder_Date

      ,[NewAppointment]

      ,

ashfaq_haseeb
Champion III
Champion III

Like this

Calls:

load  [Complaint_ID]

      ,date(floor([complaint_date])) as complaint_date

      ,[complaint_no]

      ,[count]

      ,date(floor([Reminder_Date])) as Reminder_Date

      ,[NewAppointment]

      ,