Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jagannalla
Partner - Specialist III
Partner - Specialist III

Distinct hours:Mins

Hello,

i've date field like shown below:

DateColumn

2012-07-03 15:51:53.58
2012-07-03 15:52:21.74
2012-07-03 15:52:49.89
2012-07-03 15:53:18.54
2012-07-03 15:53:46.82

- I want to retrive the distinct dates and time. I can able to do for dates. But i can't do for time how can i achive this. For date i'm using

Date(Floor(DateColumn),'MM/DD/YYYY') as Date

I WANT DISTICNT TIMES

for example

15:51

15:52

15:53

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Then you should truncate it to the nearest minute:

Time(Frac(Floor(Date,1/24/60)),'hh:mm')

HIC

View solution in original post

11 Replies
jvitantonio
Luminary Alumni
Luminary Alumni

Hi, try this in your load script:

TIME:

LOAD

Timestamp(DATE) AS DATE,

hour(DATE) as Hour, Minute(DATE) as Min

INLINE [

DATE

2012-07-03 15:51:53.58

2012-07-03 15:52:21.74

2012-07-03 15:52:49.89

2012-07-03 15:53:18.54

2012-07-03 15:53:46.82

];

HOUR:

LOAD Distinct

MakeTime(Hour,Min) as Hour1

Resident TIME;

vincent_ardiet
Specialist
Specialist

Hi,

You can use the TIME function like this : Time(DateColumn,'hh:mm')

Regards,

Vincent

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Ya i already tried with time function but it doen't give me distinct times.

QlikUser14.. I don't want the time in AM/PM. I need in 24 hours format only as what i've in my timestamp.

jvitantonio
Luminary Alumni
Luminary Alumni

That's formatted in your script:

SET TimeFormat='hh:mm:ss TT';

vincent_ardiet
Specialist
Specialist

You're right, QV doesn't make the distinct, perhaps it's due to the dual value.

But, like this it works : Time#(Time(DateColumn,'hh:mm'))

Regards,

Vincent

nagaiank
Specialist III
Specialist III

The following script works and gives distinct hh:mm

TIME:

LOAD Distinct Text(TimeStamp(DATE,'hh:mm')) as Time;

LOAD * INLINE [

DATE

2012-07-03 15:51:53.58

2012-07-03 15:52:21.74

2012-07-03 15:52:49.89

2012-07-03 15:53:18.54

2012-07-03 15:53:46.82

];

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Thanks to all.

hic
Former Employee
Former Employee

The simplest way to do this is to use the Frac() function, which just cuts of the integer part of a number, and then format it as time. Hence:

Time(Frac(Date))

HIC

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Henric Cronstrom,

But i need to distinct hours, mins time. I don't want seconds? Please see the image.

Untitled.png