date - Just the day formating in SSIS expression builder -


i'm trying format(in yyyymmdd) previous month's first day within ssis 2005 expression builder. far have managed year , month correctly represented. however, i'm stuck when comes day part of expression.

below complete errorneous code i'm trying hack.

right((dt_wstr, 4) year( dateadd( "mm",-1, getdate() )), 4) + right("0" + (dt_wstr,2) month( dateadd( "mm",-1, getdate() )), 2)+ right("0" + (dt_wstr,2) day(dateadd("mm", datediff("mm", 0, getdate())-1,0)),2) 

the first line returns year ( in yyyy format) second line returns month (mm format). however, i'm stuck @ returning day part (in format 01 or 1) in third line.

any appreciated.

there's no need fancy expression stuff day. first day of month 01 expression should had year , month plus concatenation of literal string "01"

right((dt_wstr, 4) year( dateadd( "mm",-1, getdate() )), 4) + right("0" + (dt_wstr,2) month( dateadd( "mm",-1, getdate() )), 2)+ "01" 

Comments