Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

last day of last month date expression in ssis

I have to create a derived column to upload a date in OLEDB destination because my source file doesn't contain this date. The date i want to get through derived column is last day of last month. Does anyone know how to get it?

like image 979
Kate Avatar asked Oct 21 '25 14:10

Kate


2 Answers

Try the following expression, just substract the current day from the current date using DATEADD Function.

DATEADD("d", -DAY(GETDATE()), GETDATE())

If you want to remove time you have two choices:

  1. convert to string

    LEFT((DT_STR,50,1252)DATEADD("d", -DAY(GETDATE()),GETDATE()),10)
    
  2. convert to string then to date (it will generate time 12:00 AM)

    (DT_DATE)LEFT((DT_STR,50,1252)DATEADD("d", -DAY(GETDATE()),GETDATE()),10)
    
like image 90
Hadi Avatar answered Oct 24 '25 19:10

Hadi


The simplest way if you don't need time is :

(DT_DBDATE)(DATEADD("d",-DAY(GETDATE()),GETDATE()))
like image 42
d_anass Avatar answered Oct 24 '25 18:10

d_anass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!