Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

markgraham123
Contributor II

convert year format in script

Hi All,

I have date format as 3/15/0017 11:52:58 PM in my data set.

I wanna see it as 3/15/2017 11:52:58 PM


Can someone please help?

4 Replies
antoniotiman
Honored Contributor III

Re: convert year format in script

Hi Mark,

may be

Timestamp(Timestamp#(Date,'M/D/00YY hh:mm:ss TT'),'M/D/YYYY hh:mm:ss TT') 

=Timestamp(Timestamp#('3/15/0017 11:52:58 PM','M/D/00YY hh:mm:ss TT'),'M/D/YYYY hh:mm:ss TT') 

Regards,

Antonio

markgraham123
Contributor II

Re: convert year format in script

This is not working for all fields Antonio.

Actual data set is like this - Combination of normal and other data type!

3/15/0017 11:52:58 PM

3/16/2017 11:52:58 PM

3/17/0017 11:52:58 PM

3/18/2017 11:52:58 PM

3/19/0017 11:52:58 PM

3/22/2017 11:52:58 PM

3/23/2017 11:52:58 PM

3/30/2017 11:52:58 PM

antoniotiman
Honored Contributor III

Re: convert year format in script

LOAD Alt(Timestamp(Timestamp#(Date,'M/D/00YY hh:mm:ss TT'),'M/D/YYYY hh:mm:ss TT'),Timestamp(Timestamp#(Date,'M/D/YYYY hh:mm:ss TT'),'M/D/YYYY hh:mm:ss TT'))  as Date

vishsaggi
Esteemed Contributor III

Re: convert year format in script

Write an IF condition with Antonio's timestamp function.

Like:

= IF(Left(Subfield('31/02/0017', '/',3), 2) = '00', Timestamp(Timestamp#('3/15/0017 11:52:58 PM','M/D/00YY hh:mm:ss TT'),'M/D/YYYY hh:mm:ss TT') , yourdatefield)