Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

format date qlikview macro

Hi, i get in my macro by getting the object a date which as the following format : 02/23/2015 (for instance)

however, eve if the format was a date on qlikview , in excel it turns to be a simple string.

the format i need is 23-feb-2015

i tried using the format() function but i get a type mismatched

asofdate = XLSheet.Range("B50")     // i get the date from the excel

dateformated = CDate(asofdate)        // i parse it into a date ?

AsOfDate2 = Format(dateformated,"DD-MMM-YYYY")     // i force a format

this gives me the Type mismatch: 'Format' error

not sure if my AsOfDate2 even parsed is not recognized as a date or ?

any advices? help?

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Try:

AsOfDate2 = cstr(Day(dateformated)) + "-" + cstr(Monthname(Month(dateformated), true)) + "-" + cstr(Year(dateformated))

Hope this helps!

View solution in original post

7 Replies
Not applicable
Author

Is there a reason you are using .Range on a single cell?  Maybe try... asofdate = Cells(B,50).value

Not applicable
Author

the macro module of qlikview does not let me use this Cells ...

Not applicable
Author

Is XLSheet a variable that stores the current active document?  If so perhaps... asofdate = XLSheet.Cells(B,50).value    Could you post the entire macro?

Not applicable
Author

thanks, for the help so far, here is the look of it (i get some errors if i use cell)

sub Export

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = false

XLApp.DisplayAlerts = False

set XLDoc = XLApp.Workbooks.Add

set XLSheet = XLDoc.Worksheets(1)

'-----------------

' some stuf happening here not related

'-----------------

' i get the object containing my date here

set Mytable9 = ActiveDocument.GetSheetObject("MB05")

set XLSheet = XLDoc.Worksheets(1)

Mytable9.CopyTableToClipboard true

XLSheet.Paste XLSheet.Range("A50")

DateText = DateValue(XLSheet.Range("B50").value)

asofdate = XLSheet.Range("B50").value

'asofdate = XLSheet.Cells(B,50).value =----> does not work : unknown runtime error

'-----------------

' some stuf happening here not related

'-----------------

end

jerem1234
Specialist II
Specialist II

Try:

AsOfDate2 = cstr(Day(dateformated)) + "-" + cstr(Monthname(Month(dateformated), true)) + "-" + cstr(Year(dateformated))

Hope this helps!

jerem1234
Specialist II
Specialist II

You can also try:

AsOfDate2 = activedocument.Evaluate("Date('" & activedocument.Evaluate("date#('" & dateformated & "', 'DD/MM/YYYY')") & "', 'DD-MMM-YYYY')")

Hope this helps!

Not applicable
Author

thanks, works perfectly !!!