Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

ecabanas
Contributor

Problems with Date format

Hi all,

I'm loading dates from sql server that comes with this format: 2011-08-25 00:00:00.000

I create a Calendar with:

LET vDateMin = Num(MakeDate(2011,1,1)); 

LET vDateMax = Floor(MonthEnd(Today())); 

LET vDateToday = Num(Today()); 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////TEMPCALENDAR///////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

TempCalendar: 

LOAD

$(vDateMin) + RowNo() - 1 AS DateNumber, 

Date($(vDateMin) + RowNo() - 1) AS TempDate 

AUTOGENERATE 1 

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax); 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////CALENDAR///////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Calendar: 

LOAD

  Floor(TempDate)  AS DATEFINANCIAL_LINE,

The problem is when I load in the script:

floor(DATEFINANCIAL) as DATEFINANCIAL_LINE

There are some lines tha did not match with the Calendar and I'm getting fool to find the mistake

Many thank's

Eduard

Tags (1)
6 Replies

Re: Problems with Date format

Try this

LET vDateMin = Num(MakeDate(2011,1,1));

LET vDateMax = Num(MonthEnd(Today()));

LET vDateToday = Num(Today());

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////TEMPCALENDAR///////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

TempCalendar:

LOAD

  $(vDateMin) + RowNo() - 1 AS DateNumber,

  Date($(vDateMin) + RowNo() - 1) AS TempDate

AUTOGENERATE 1

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////CALENDAR///////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Calendar:

LOAD

  Date(TempDate)  AS DATEFINANCIAL_LINE

Resident TempCalendar;

Drop Table TempCalendar;

Date(floor(DATEFINANCIAL)) as DATEFINANCIAL_LINE

Re: Problems with Date format

May be try this:

TempCalendar:

LOAD

$(vDateMin) + RowNo() - 1 AS DateNumber,

Date($(vDateMin) + RowNo() - 1, 'YYYY-MM-DD') AS TempDate

AUTOGENERATE 1

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////CALENDAR///////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Calendar:

LOAD

  TempDate  AS DATEFINANCIAL_LINE,

Fact_Table:

Date(Floor(TimeStamp#(DATEFINANCIAL, 'YYYY-MM-DD')), 'YYYY-MM-DD') as DATEFINANCIAL_LINE

sasiparupudi1
Honored Contributor III

Re: Problems with Date format

LET vDateMin = Num(MakeDate(2011,1,1));

LET vDateMax = Floor(MonthEnd(Today()));

LET vDateToday = Num(Today());

TempCalendar:

LOAD

$(vDateMin) + RowNo() - 1 AS DateNumber,

Date($(vDateMin) + RowNo() - 1) AS TempDate

AUTOGENERATE 1

WHILE $(vDateMin)+IterNo()-1<= $(vDateMax);

Cal:

LOAD *,

Floor(TempDate) AS DATEFINANCIAL_LINE Resident TempCalendar;

DROP Table TempCalendar;

Data:

Load SqlDate

,Date(if(SubStringCount(SqlDate,' ')>0,Timestamp#(SqlDate,'YYYY-MM-DD hh:mm:ss[.fff]'),SqlDate)) as SqlDate1

Inline

[

SqlDate

2011-08-25 00:00:00.000

2011-01-25

2011-02-22 00:00:00.000

]

sasiparupudi1
Honored Contributor III

Re: Problems with Date format

Hi

Is your problem solved?

Sasi

ecabanas
Contributor

Re: Problems with Date format

Hi Sasidhar,

the problem was there were some dates "null" , I tryied another date field like phisical date that has allways data

Many thank's guys

Eduard

sasiparupudi1
Honored Contributor III

Re: Problems with Date format

Please close this thread then marking your resolution as a correct answer

Community Browser