Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Krish2459_58
Creator
Creator

dates format issue

Hi ,

I have dates in the below format and when I apply the date conversion (DATE([Lease Commencement],'MM/DD/YYYY')) the left side dates are not visable. Please suggest.

 

Krish2459_58_0-1718863186181.png

 

Labels (2)
1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Where are you from and what date region/format is used in your region. 

You are trying to Convert date which hase DAY/MONTH/YEAR using american - MONTH/DAY/YEAR and timestamp format?

Since you are loading data from excel this can cause a lot of issues an problems as excel itself will try to convert values to dates and depending in which region you open it it may be say 1st of March 2024 or 3rd of January 2024..

As you can see the same issue we have directly in Excel:

Lech_Miszkiewicz_0-1718867948063.png

 

Anyway - I have loaded your data and I didnt have any issues.

Try loading this data using below script and inspect in data model viewer how fields are loaded:

 

[test]:
LOAD
	[Lease Commencement]
	,Text([Lease Commencement] ) AS [Text Lease Commencement]
    ,Date([Lease Commencement] ) AS [Date Lease Commencement]
    
	,Date(Alt(
    	[Lease Commencement]
    	,Date#(Trim(Text([Lease Commencement])),'D/M/YYYY')
        ,Date#(Trim(Text([Lease Commencement])),'D/MM/YYYY')
    	,Date#(Trim(Text([Lease Commencement])),'DD/MM/YYYY')       
        )) 
        						AS [Fixed Lease Commencement]
 FROM 
 	[lib://DataFiles/Test (1).xlsx]
(ooxml, embedded labels, table is test);

 

Lech_Miszkiewicz_1-1718868943351.png

 

Also check what are the MAIN variables settings:

Lech_Miszkiewicz_2-1718869011057.png

 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

6 Replies
Krish2459_58
Creator
Creator
Author

attached the actual data for date.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Krish2459_58 

make sure you study what Date() and Date#() functions do. 

There is significant difference between them

Now records at the top are not recognized as date/numerical types, and instead they are just loaded as text. You can convert them to dates using Date#() function before using Date() function to apply mask on the numerical value of the date.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Krish2459_58
Creator
Creator
Author

@Lech_Miszkiewicz ,

I have tried this to convert : Alt( Timestamp#([Lease Commencement],'M/D/YYYY h:mm tt')) as [Lease Commencement]

I got this. Did I miss anything here.

Krish2459_58_0-1718865942105.png

 

lennart_mo
Contributor III
Contributor III

Hi @Krish2459_58 ,

You got the idea partly right. You need to add the second date format to your Alt() Function. As you can see it transforms your specified date format into numbers but not the other one. So applying something like this formula:

=Alt(Date#([Lease Commencement],'M/D/YYYY'),Date#([Lease Commencement],'DD/MM/YYYY') as[Lease Commencement]

Should give you all dates as number values. To transform it into dates just add the Date() function before the Alt() with your desired date format.

TauseefKhan
Creator III
Creator III

Check by loading this In your script:

DATE(DATE#([Lease Commencement],'DD/MM/YYYY')) AS [Lease Commencement],


Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Where are you from and what date region/format is used in your region. 

You are trying to Convert date which hase DAY/MONTH/YEAR using american - MONTH/DAY/YEAR and timestamp format?

Since you are loading data from excel this can cause a lot of issues an problems as excel itself will try to convert values to dates and depending in which region you open it it may be say 1st of March 2024 or 3rd of January 2024..

As you can see the same issue we have directly in Excel:

Lech_Miszkiewicz_0-1718867948063.png

 

Anyway - I have loaded your data and I didnt have any issues.

Try loading this data using below script and inspect in data model viewer how fields are loaded:

 

[test]:
LOAD
	[Lease Commencement]
	,Text([Lease Commencement] ) AS [Text Lease Commencement]
    ,Date([Lease Commencement] ) AS [Date Lease Commencement]
    
	,Date(Alt(
    	[Lease Commencement]
    	,Date#(Trim(Text([Lease Commencement])),'D/M/YYYY')
        ,Date#(Trim(Text([Lease Commencement])),'D/MM/YYYY')
    	,Date#(Trim(Text([Lease Commencement])),'DD/MM/YYYY')       
        )) 
        						AS [Fixed Lease Commencement]
 FROM 
 	[lib://DataFiles/Test (1).xlsx]
(ooxml, embedded labels, table is test);

 

Lech_Miszkiewicz_1-1718868943351.png

 

Also check what are the MAIN variables settings:

Lech_Miszkiewicz_2-1718869011057.png

 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.