Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Miguel_Angel_Baeyens

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

Anonymous
Not applicable
Author

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.

Miguel_Angel_Baeyens

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

Anonymous
Not applicable
Author

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