Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
I just need conversion of to_timestamp, to_char, add_months
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
thank u:)
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
You can make the answer as correct or helpful, so that indicate other members that issue has been taken care.
thanks,
angad