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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
gz
Creator
Creator

extracting time

Hi, I have column data_start with date in format 2017-03-08 07:12:51.000000
I need extract only time in hh:mm:ss
I tried 

Mid(data_start, 12, 8) as data_start_time
Time(Time#(data_start, 'hh:mm:ss')) as data_start_time

Time(Timestamp#(data_start, 'YYYY-MM-DD hh:mm:ss.ffffff')) as data_start_time

Time(Mid(data_start, 12, 8)) as data_start_time

nothing works

Labels (2)
2 Solutions

Accepted Solutions
RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @gz 

as Qlik will understand data as a timestamp without Timestamp#()

RafaelBarrios_0-1733748829426.png

you can do 

=time(start_Date)

RafaelBarrios_1-1733748997165.png

 

if for any reason you need to split in script, you can

RafaelBarrios_4-1733749137188.png

 

Qlik should understand those as date and time fields

RafaelBarrios_5-1733749150841.png

time() to change output format

 

Hope this helps.

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button!


best,


View solution in original post

marksouzacosta

Hi @gz,

Please try the code below - the highlighted bold part is the only one you need.

MyTable:
Load
DateTimeField,
Num(DateTimeField) AS DateTimeFieldNumeric,
Floor(DateTimeField) AS DateNum,
Frac(DateTimeField) AS TimeNum,
Date(Floor(DateTimeField)) AS Date,
Time(Frac(DateTimeField)) AS Time
INLINE [
DateTimeField
2017-03-08 07:12:51.000000
];

marksouzacosta_0-1733754929858.png

 

Qlik stores Date and Time values as integers + decimals. The integer part is the Date while the decimal is the time. Floor extracts the integer part, meaning only the Date, without time. The Frac is the opposite. 

Date and Time functions are only FORMAT functions, they do not change the VALUE of the field - even if they look changed in your charts. This is very important to keep in mind. 

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

View solution in original post

7 Replies
RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @gz 

as Qlik will understand data as a timestamp without Timestamp#()

RafaelBarrios_0-1733748829426.png

you can do 

=time(start_Date)

RafaelBarrios_1-1733748997165.png

 

if for any reason you need to split in script, you can

RafaelBarrios_4-1733749137188.png

 

Qlik should understand those as date and time fields

RafaelBarrios_5-1733749150841.png

time() to change output format

 

Hope this helps.

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button!


best,


gz
Creator
Creator
Author

gz_0-1733750958142.pnggz_1-1733751008582.png

this dosen't work 

Time(SubField(data_start,' ',2),'hh:mm:ss') as data_start_final

QFabian
MVP
MVP

Hi @gz  please try this option.

QFabian_1-1733752002528.png

 

Script: 

SET DateFormat='YYYY/MM/DD';
SET TimestampFormat='YYYY/MM/DD hh:mm:ss';

Aux:
Load * INLINE [
DateField
2017-03-08 07:12:51.000000
];

Load
DateField as Date_Ori,
Timestamp(DateField) as Date
Resident Aux;

exit script;
Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
gz
Creator
Creator
Author

In Script i'm using 
SET DateFormat='DD.MM.YYYY';
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';

RafaelBarrios
Partner - Specialist
Partner - Specialist

strange 

but i see you have it on date_start_time3

 

are you doing any calculation ?

can you paste all section script ?

 

Best,

marksouzacosta

Hi @gz,

Please try the code below - the highlighted bold part is the only one you need.

MyTable:
Load
DateTimeField,
Num(DateTimeField) AS DateTimeFieldNumeric,
Floor(DateTimeField) AS DateNum,
Frac(DateTimeField) AS TimeNum,
Date(Floor(DateTimeField)) AS Date,
Time(Frac(DateTimeField)) AS Time
INLINE [
DateTimeField
2017-03-08 07:12:51.000000
];

marksouzacosta_0-1733754929858.png

 

Qlik stores Date and Time values as integers + decimals. The integer part is the Date while the decimal is the time. Floor extracts the integer part, meaning only the Date, without time. The Frac is the opposite. 

Date and Time functions are only FORMAT functions, they do not change the VALUE of the field - even if they look changed in your charts. This is very important to keep in mind. 

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

gz
Creator
Creator
Author

 

[bq_factoring_invoice_status_history]:
LOAD id_faktury as id_faktury_his , 
id_sprawy, 
data_start, 
data_stop, 
status_faktury,
    Date(Left(data_start, 10)) as data_start_date, //  YYYY-MM-DD
    Time(Timestamp#(data_start, 'YYYY-MM-DD hh:mm:ss.ffffff')) as data_start_time,
    Time(Time#(data_start, 'hh:mm:ss')) as data_start_time1,
    Time(Mid(data_start, 12, 8),'hh:mm:ss') as data_start_time2,
    Time(data_start) as data_start_time3,
    Time(SubField(data_start,' ',2),'hh:mm:ss') as data_start_final
    
   
    ;
 
[bq_factoring_invoice_status_history]:
SELECT "id_faktury",
"id_sprawy",
"data_start",
"data_stop",
"status_faktury"
FROM "qlick"."bq_factoring_invoice_status_history";
gz_1-1733755264297.png