Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date & Time

Hi all

I am importing date fields from two different tables from a Firebird database.

Looking at the data types in the Firebird database, they are all just 'Date' rather than 'DateTime'.

However, the fields that I import from Table B result in the time portion of 00:00:00 being added, even though when I load them in to the final table I use the Floor() function.

Obviously, I can just format any data tables accordingly but I would rather have uniform data types, especially for dates.

Can anyone help?

Thanks

James

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

The time portion is just formatting - added by either the ODBC or by QlikView in the load phase.

QlikView does not have any data types (See this article). If it is a number and you have used the floor function, you are all set. You should/could use a Date() function on top of it to get the formatting right, but this is almost just "cosmetics". All numeric evaluations and sorting are based on the number you created with the Floor() function.

So, if you want to debug, and see what goes on, format it as a number instead: Num(DATE_SETUP).

And the NULL test is better made with

     If(Len(Trim(DATE_SETUP))>0, DATE_SETUP) AS LeadDate, or   

     If(IsNum(Date#(DATE_SETUP)), Date#(DATE_SETUP)) AS LeadDate

This way you also catch values that contain spaces.

HIC

View solution in original post

11 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Format the dates using the

Date(DateField, 'MM/DD/YYYY')

Regards,

Jagan.

sujeetsingh
Master III
Master III

yes go with Date functions to format them

Not applicable
Author

try according to this date format.

date(date#(datefieldtable1,'DD-MM-YYYY'),'DD/MM/YYYY')

date(date#(datefieldtable2,'MM-DD-YYYY'),'DD/MM/YYYY')

Not applicable
Author

Thanks for the posts.

Unfortunately, just using the Date function is not producing consistent results.

I am using this QlikView script to transform data imported from a Firebird database, so I think I need to understand if there are any implicit conversions happening.

Here is a typical transfomation statement that I am using for a date (as I don't want any zero length strings in the field)

If(DATE_SETUP = '', Null(), DATE_SETUP) AS LeadDate

miikkaqlick
Partner - Creator II
Partner - Creator II

Hi!

I sometimes use Left-function to get rid of time:

DateTime = 2014/01/01 00:00:00

Left(DateTime,10) = 2014/01/01

You might need to convert this little more to match another date-type.

Br,

Miikka

CELAMBARASAN
Partner - Champion
Partner - Champion

Please check the field is in date format or simply text?

Goto Document properties --> Tables --> Check the Tag for the Field "LeadDate". If tag has $number then probably it is in date format. Then use

     If(DATE_SETUP = '', Null(), Date(DATE_SETUP)) AS LeadDate

No $number tag you need to convert it in to date format by using date# function.

To use date# function you need to analyse in which format it is getting loaded to qlikview.

MM/DD/YYYY or DD/MM/YYYY or DD-MM-YYYY or MM-DD-YYYY

If(DATE_SETUP = '', Null(), Date(Date#(DATE_SETUP, "MM/DD/YYYY"))) AS LeadDate

Anonymous
Not applicable
Author

Hi James,

         can you please share only dates form you data,just two to three rows only.

   other wise share the data formats you getting.

Thanks

SHAIK

hic
Former Employee
Former Employee

The time portion is just formatting - added by either the ODBC or by QlikView in the load phase.

QlikView does not have any data types (See this article). If it is a number and you have used the floor function, you are all set. You should/could use a Date() function on top of it to get the formatting right, but this is almost just "cosmetics". All numeric evaluations and sorting are based on the number you created with the Floor() function.

So, if you want to debug, and see what goes on, format it as a number instead: Num(DATE_SETUP).

And the NULL test is better made with

     If(Len(Trim(DATE_SETUP))>0, DATE_SETUP) AS LeadDate, or   

     If(IsNum(Date#(DATE_SETUP)), Date#(DATE_SETUP)) AS LeadDate

This way you also catch values that contain spaces.

HIC

Anonymous
Not applicable
Author

goodmorning. replying just not to open a new thread... i'm importing from a database where date and time are 2 different columns (i.e. for each day/date i have as many rows as records are acquired through the timeline); i'd like to concatenate i have to do calculations over another DB where the field "time" has all the parameters (DD/MM/YYYY hh:mm). how can i do that, i.e. not only concatenate characters but obtain a sort of numeric field to use with calculations? thanx