Monday, 2 November 2015

How to get the Last Day of the Given Date Data.



I am taking the Data Like below

Country Date_DB Sales Date_DB2
A     12-12                 200        12-2012
B     10-15                300        10-2015
C     02-12                20        02-2012

We are expecting like Below

Country    Sales   DB_Date_DB      LDM
A              200       12-12                31-Dec-2012
 

Procedure:

1) First Convert the Given Date Related column into exact Date like using below calculation.
(This Calculation for Date_DB, it means Date is Like 10-12)
date( "01" +  "/" +  str(left([Date DB],2))  +"/" +( "20" + str(right([Date DB],2))))



2) Use the below Calculation to Last day of the Given Date.
datepart( 'day', dateadd('day', -1, dateadd('month', 1,[Converttodate_MM-YY])))


3) Expected Output.




===============

If data is available like 12-2012 then use the below calculation to Convert into Date.
date( "01" +  "/" +  str(left([Date DB2],2))  +"/" +  str(right([Date DB2],4)))


No comments :

Post a Comment