Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

WernerDC
New Contributor II

Date formatting in script

Hi,

I am having trouble with converting dates to Month and year.

This is what I did:

Date#(@2) AS                       [WEATHER DATE],
Year(Date#(@2)) AS           [WEATHER YEAR], 
Month(Date#(@2)) AS      [WEATHER MONTH]

When I do list boxes, only the Date 1 displays data. Not Year nor Month shows any data?

I also tried this:

Date#(@2) AS                       [WEATHER DATE],
Year(Date(@2)) AS           [WEATHER YEAR], 
Month(Date(@2)) AS      [WEATHER MONTH]

Also no success.

 

Please advise

 

Labels (1)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Date formatting in script

It appears your input date uses / as the separator, so you should specify:

'DD/MM/YYYY'

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

4 Replies
Partner
Partner

Re: Date formatting in script

You should specify which format your date in @2 is stored.
If today is stored as 2019-04-16 then you should type 'YYYY-MM-DD' like below

dayname(Date#(@2,'YYYY-MM-DD')) AS [WEATHER DATE],
Year(Date#(@2,'YYYY-MM-DD')) AS [WEATHER YEAR],
Month(Date#(@2,'YYYY-MM-DD')) AS [WEATHER MONTH]
Plees ekskuse my Swenglish and or Norweglish spelling misstakes
WernerDC
New Contributor II

Re: Date formatting in script

Thank you for the response.

It however still does not work?

(Date#(@2,'DD-MM-YYYY')) AS [WEATHER DATE],
Year(Date#(@2,'DD-MM-YYYY')) AS [WEATHER YEAR],
Month(Date#(@2,'DD-MM-YYYY')) AS [WEATHER MONTH],

And 

dayname(Date#(@2,'DD-MM-YYYY')) AS [WEATHER DATE],
Year(Date#(@2,'DD-MM-YYYY')) AS [WEATHER YEAR],
Month(Date#(@2,'DD-MM-YYYY')) AS [WEATHER MONTH],

 

Please advise

 

MVP & Luminary
MVP & Luminary

Re: Date formatting in script

It appears your input date uses / as the separator, so you should specify:

'DD/MM/YYYY'

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

WernerDC
New Contributor II

Re: Date formatting in script

Perfect. Thank you.

 

Seems like dates can really push you around