Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jerryr125
Creator III

Variables - Convert Date to Numeric Value

Hi - I have the following variable:

 

vForecastDateStart

=date(today(),'MM/DD/YYYY')

 

I would like to convert it to a numeric value such as YYYYMMDD

 

I tried this :

vForecastDateStartNumeric:

num(left(Date($(vForecastDateStart),'MM/DD/YYYY'),4)&left(right(Date($(vForecastDateStart),'MM/DD/YYY'),4),2)&right(Date($(vForecastDateStart),'MM/DD/YYY'),2))

 

No luck - any thoughts ? thanks - Jerry

 

1 Solution

Accepted Solutions
johngouws
Partner - Specialist

Hi Jerry,

I think Date# will do it. 

Date(Date#($(vForecastDateStart),'YYYY-MM-DD'),'YYYY/MM/DD')

 

View solution in original post

6 Replies
rubenmarin

Hi, with simple quotes for variable value it should work, also you need to change the date format:

num(left(Date('$(vForecastDateStart)','YYYYMMDD'),4)&left(right(Date('$(vForecastDateStart)','YYYYMMDD'),4),2)&right(Date('$(vForecastDateStart)','YYYYMMDD'),2))

Or just:

=Num#(Date('$(vForecastDateStart)','YYYYMMDD'),'0')

PrashantSangle

date(Today(),'YYYYMMDD')

or

num#(date(today(),'YYYYMMDD'))

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Vegar
MVP

Do you want to present it as Date with format YYYYMMDD or do you want to store it as the number YYYMMDD?

If date with format then your got the answer from earlier repliers.

If number then you would need to wrap text(), num(text())  or evaluate (text()) around it.

Like this

Num( Text( Date( date#('$(v Forecast DateStart)', 'MM/DD/YYYY'), 'YYYYMMDD'))) 

johngouws
Partner - Specialist

Hi Jerry,

I think Date# will do it. 

Date(Date#($(vForecastDateStart),'YYYY-MM-DD'),'YYYY/MM/DD')

 

Usama
Creator

Hi,

You can try this:

=Num#(Date('$(vForecastDateStart)','YYYYMMDD'),'0')

Thanks,

Usama

From Nothing - To Something - To Everything
jerryr125
Creator III
Author

perfect ! Thank you !