Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
viveksingh
Creator III
Creator III

Distinct date from timestamp

Hi Experts,

I have CALENDAR_DATE field in Time stamp format, which is like 2001-01-13 00:00:00.000000

I  extracted Date from the Time stamp with  Date(Timestamp(CALENDAR_DATE),'MMM-YY')

and the output shows as

JAN-01

JAN-01

FEB-01

JAN-02

FEB-02

FEB-02

JAN-03

FEB-03

I want this as which is unique records along with sort.

JAN-01

FEB-01

JAN-02

FEB-02

JAN-03

FEB-03

Thanks,

Vivek

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try

Date(Monthstart(CALENDAR_DATE),'MMM-YY')

View solution in original post

12 Replies
arulsettu
Master III
Master III

can you post sample data

viveksingh
Creator III
Creator III
Author

Hi Arul,

my date field is in TIMESTAMP format like 2001-01-13 00:00:00.000000

when I use with below expression

date.PNG

I will get output like

caldate.PNG


I want this to be in UNIQUE and it needs to be sort.

arulsettu
Master III
Master III

if your timestamp is like this 2001-01-13 00:00:00.000000

then your output should be

2001-01-13

that means

jan-01

right?

post some excel data

rahulpawarb
Specialist III
Specialist III

Hello Vivek,

You can use below given sample code snippet in script.

Date(Date#(Left(CALENDAR_DATE,10), 'DD/MM/YYYY'), 'MMM-YY') AS Date

Hope this will be of help!

Regards!

Rahul

viveksingh
Creator III
Creator III
Author

Yes, you are correct. I Just wrote as an example.

Below are my sample data

vinieme12
Champion III
Champion III

use DATE#( Date(Timestamp(CALENDAR_DATE),'MMM-YY'))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
viveksingh
Creator III
Creator III
Author

Hi Vineeth,

Thanks for the reply, expression is working fine . but we need to sort it in a chart.

now it it showing as

APR-01,APR-03,AUG-01,FEB-01.

it should sort as per calendar like FEB-01,APR-01,AUG-01,APR-03

rahulpawarb
Specialist III
Specialist III

Hello Vivek,

You can sort the dimension based on expression (Chart Properties-> Sort Tab). If the dimension field is Date then use

Date(Date,'YYYYMM') in expression box and set the sort order as Ascending.

Regards!

Rahul

PrashantSangle

Hi,

use floor and date() in script.

try below

date(floor(dateField),'MMM-YY') as monthYear

and use new field in your object.

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂