March 24, 2011 at 2:26 am
Hi All
The date format is YYYYMMDD_hhmmss
For that i have wriiten like below in script task.
Year(Now.Date).ToString + Month(Now.Date).ToString + Day(Now.Date).ToString + "_" + Hour(Now).ToString + Minute(Now).ToString + Second(Now).ToString
If date is 14/10/2010
then output is 20101014_154258
if it is 5/9/2010
then 201095_154258
But I want it in 20100905_154258 format.[Min and Sec are coming like this also]
thanks
Rohit
March 24, 2011 at 2:33 am
I'm not au fait with scripts but within SSIS I added the following before my month and date fields :
((dt_wstr,2)len((dt_wstr,2)month(getdate()))=="2"?"":"0")
which is saying "if the month is 2 chars long do nothing else add a zero" - you might be able to adapt for your script.
March 24, 2011 at 4:45 am
Hi
It can be done by following way
Now.Date.ToString("yyyy") + Now.Date.ToString("MM") + Now.Date.ToString("dd") + "_" + Now.ToString("HH") + Now.ToString("mm") + Now.ToString("ss")
thanks
Rohit
April 13, 2011 at 12:06 pm
You don't need to make it that complicated.
Just use this:
Now.ToString("yyyyMmdd_HHmmss")
QUIGROUP- Need a Certified experienced DBA for a project or troubleshooting? Need help with programming, database recovery, performance tuning, ETL, SSRS or developing new databases? Contact us.. 1-786-273-9809
April 13, 2011 at 12:14 pm
I assume you have a reason to format the date as a string in that format, but if not then you should really look into formatting in an ISO format.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply