Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

thnkgreen
Contributor

DateSerial function in QlikView

Hello.  I am trying to re-write a SQL statement from Access into QlikView.  A portion of the Access SQL statement uses the DateSerial function.  I know that QlikView does not use this same function, so how do I get QlikView to do the same thing?  Thank you.

Original code:

If(MIN(PSNUM2)<>0,DateSerial(Left(MIN(PSNUM2),4),Mid(MIN(PSNUM2),5,2),Right(MIN(PSNUM2),2)),0) AS START_SHIP_DATE

4 Replies
MVP
MVP

Re: DateSerial function in QlikView

Hi,

To create dates from different fields or expressions, use the MakeDate() function. Your expression should be like

If(Min(PSNUM2)<>0, MakeDate(Left(Min(PSNUM2), 4), Mid(Min(PSNUM2), 5, 2), Right(Min(PSNUM2), 2)), 0) AS START_SHIP_DATE

or even easier, if the input format is always the same:

Date(Date#(PSNUM2, 'YYYYMMDD')) AS START_SHIP_SATE

Hope that helps.

Miguel

thnkgreen
Contributor

Re: DateSerial function in QlikView

Thanks so much for helping me with this Miguel. One question, though. Why did you insert the Min keyword in different places? Does it have to be there? Thanks.

MVP
MVP

Re: DateSerial function in QlikView

Hi,

I was just copying and pasting from your example line, I was trying to show how the MakeDate() function works. Min() does not have to be there if you don't need it.

Miguel

thnkgreen
Contributor

Re: DateSerial function in QlikView

Ok. I understand. Thank you so much for your help ☺

Community Browser