Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Wrong dates

Hi,

The below logic is used to derive dates in qlikview,

Date#(Num(Month([REPORTDT]))&'/01/'&(Year([REPORTDT])-1), 'MM/DD/YYYY') as ReportingDate

But it gives dates as

1/01/4994

3/01/4993......

Which is not an correct dates.

Thanks..

6 Replies
pra_kale
Creator III
Creator III

maniram23
Creator II
Creator II

Hi,

In the REPORTDT what type of data you having.

Can you please share the data.

Other wise replace date# in the place of date .

maxgro
MVP
MVP

if your field REPORTDT is a text, you need the date#  function to interpret the date

date#(REPORTDT, 'format of reportdt')

and then, to format the date

date(date#(REPORTDT, 'format of reportdt'), 'format of reporting date')

          OR (this use the date format of the SET DateFormat you can find at the beginning of your script)

date(date#(REPORTDT, 'format of reportdt'))


your script should be

.....

date(date#(REPORTDT, 'format of reportdt'), 'format of reporting date') as ReportingDate

....


format code are here

https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/conventions-number-time-formats....



an example in the image

1.png

HirisH_V7
Master
Master

Hi,

Can you share sample of your original Data without transformations.

that will be helpful to look into the Format.

-Hirish

HirisH
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Using Massimo's explanation as a starting point, there is an easier way to get the date of the first of the month. In the next example, replace format of reportdt with the actual format of the input dates in field REPORTDT. Because that's probably where the problems with dates 2900 years in the future start:

:

MonthStart(Date#(REPORTDT, 'format of reportdt')) AS ReportingDate,

:

This expression will use the default Date Format String (see the SET statements at the top of your script) to store reporting dates. If you want to change the format of values in ReportingDate, add a call to the Date() function to modify the result to your taste.

Peter

maniram23
Creator II
Creator II

Hi,

I Think this is useful for you..

Check it.

Date(Num(Month([REPORTDT]))&'/01/'&(Year([REPORTDT])-1))