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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

statement in sqlserver

Hi...

Can anybody help me in converting the below statemen in SQL server:

    case when TO_TIMESTAMP(to_char(MER_FROM_DTTM,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS') >= add_months(sysdate,-3) then 1 else 0 end as LM3_FLAG

Thanks in advance

7 Replies
maksim_senin
Partner - Creator III
Partner - Creator III

Hi,

It's worth to describe (a) what your purpose is and (b) what inputs are, otherwise it's not quite clear what you need to get from the expression.

Best regards,

Maxim

Not applicable
Author

TO_TIMESTAMP(to_char(MER_FROM_DTTM,'DD/MM/YYYY HH24:MI:SS'),'DD/MM/YYYY HH24:MI:SS') >= add_months(sysdate,-1) then 1 else 0 end as LM3_FLAG..

Here we have a requirement to get last 1 months data with reference to the sysdate and the timestamp is in the format: ex: 'DAY dd-MM-yyyy' like Mon 23-02-2013

Not applicable
Author

I just need conversion of to_timestamp, to_char, add_months

Not applicable
Author

Hello Acrobat,

In SQL Server, you need to use CAST or CONVERT for to_timestamp and to_char and for add_months you have to use DateAdd() function

Cast or Convert :

http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx

DateAdd :

http://msdn.microsoft.com/en-IN/library/ms186819.aspx

Thanks,

itsangad

Not applicable
Author

thank u:)

maksim_senin
Partner - Creator III
Partner - Creator III

Again it depends on the purpose - I'm not sure that you need to do this at SQL Server side, frequently (usually) flags are calculated in QlikView for a range(s) of dates when each date has flags which defines whether a date in last year, last month, last week, etc.

If you only need to calculate such flag(s) search for "calendar", "master calendar" at Community forums maybe you'll find this approach more suitable.

Best regards,

Maxim

Not applicable
Author

You can make the answer as correct or helpful, so that indicate other members that issue has been taken care.

thanks,

angad