Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Converting timestamp to a number in SQL

Hi

I created a standard incremental loader based on the Date field. I'm having difficulties changing the data format of my date field to a number. Date format in SQL database: 2015-02-04 00:00:00:.0000000', I want to replace this with a number format, i.e. 42040, within the SQL part of the load script (I need this in my where clause). Any ideas how this can be achieved?

Thanks

11 Replies
Gysbert_Wassenaar

Timestamps are numbers. You don't have to convert the timestamp value to use it as a number.


talk is cheap, supply exceeds demand
Not applicable
Author

Actually it is a character string, I just run the script again and this is the error:

Conversion failed when converting date and/or time from character string.

any ideas?

awhitfield
Partner - Champion
Partner - Champion

What's the datatype of your date in SQL?

if it's datetime2 then: 'Explicit conversion from data type datetime2 to int is not allowed.'

spividori
Specialist
Specialist

Hi.

I use the following:

num(date(left(ColumnDate,10),'DD-MM-YYYY'))

Regards.

Not applicable
Author

I tried this but 'date' is not a recognized built-in function name

my where clause is in the SQL part of the script under SQL Select

awhitfield
Partner - Champion
Partner - Champion

Can you post your SQL select please?

spividori
Specialist
Specialist

Sorry, this is for use in the load.

Regards.

gandalfgray
Specialist II
Specialist II

Hi Katarzyna


can you post the relevant part of your where clause here, please?

Gysbert_Wassenaar

Use the CAST function in sql or the timestamp# function in a qlikview load statement.


talk is cheap, supply exceeds demand