Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
mario-sarkis
Creator II
Creator II

script

please help

i have this field

DateTime

1/6/2015 06:10:32PM

i need to extract only 1/6/2015 .

and please that this function didn't work  it gives me a empty field:

Date(Floor(Date#(DateTime, 'M/D/YYYY h:mm:ssTT'))) As Date

so i am thinking to use the index function if it works and how to write it is it like this ?

Left(DateTime,index(DateTime," ") as Date ?

then i will get 1/6/2015 ?

Thank you ,

6 Replies
salto
Specialist II
Specialist II

Hi,

did you try:

Date(DateTime,'DD/MM/YYYY') as Date

HTH.

sunny_talwar

Try this:

Date(Floor(Date#(DateTime, 'M/D/YYYY hh:mm:ss tt')), 'M/D/YYYY') As Date

Gysbert_Wassenaar

Your format string isn't correct. There's a preceding 0 before the 6, so the format should have hh:mm instead of h:mm.

Or perhaps your DateTime function is already a timestamp. Have you tried simply date(floor(DateTime),'M/D/YYYY')?


talk is cheap, supply exceeds demand
Not applicable

Hi Mario,

Try this if you want to use the Index function:

Left(DateTime,Index(DateTime,' ')-1) as Date

mario-sarkis
Creator II
Creator II
Author

Well Thank you Guyz it works with me like this

Makedate(year(DateTime),Month(DateTime),Day(DateTime)) as Date.

But i need to know why it works like this.

Clever_Anjos
Employee
Employee

Please test:

Date(Date#(subfield(DateTime,' ',1),'M/D/YYYY'))