Putting The Date And Time In A Log Filename

Mar 11, 2008

Here's what I want:
I have a DTSX package run as a SQL Server agent job, that each time it runs I want it to create a new log file with the date & time in the filename.
e.g. MyJobLog.20080311_103613.txt

I have implemented this using the SSIS log provider for Text Files, and defining the Connection String as an expression as follows:-




Code Snippet"MyJobLog." + (DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() )) +RIGHT("0" + (DT_STR, 2, 1252) MONTH( GETDATE() ), 2) +RIGHT("0" + (DT_STR, 2, 1252) DAY( GETDATE() ), 2)+ "_" +RIGHT("0" + (DT_STR, 2, 1252) datepart("hh", GETDATE() ) , 2)+RIGHT("0" + (DT_STR, 2, 1252) datepart("mi", GETDATE() ) , 2)+RIGHT("0" + (DT_STR, 2, 1252) datepart("ss", GETDATE() ) , 2)+".txt"






Here's the problem:-
When the job runs, each time it tries to write to the log file it re-evaluates the filename, and as the seconds pass by the name changes! So instead of one file I end up with several:-
e.g.
MyJobLog.20080311_103613.txt
MyJobLog.20080311_103614.txt
MyJobLog.20080311_103615.txt


So the one execution of the job is now divided across three files! This is not what want!

Here's one way I fixed it:-
One of my Jobs is run from an MS-DOS batch file, so I was able to pass the constructed date/time sting into the DTSX file as a parameter. This works perfectly.

Here's my problem:-
Three more of my jobs are run as scheduled job from SQL Server Agent, so I can't pass in the date/time as a parameter each time (unless you know otherwise). And the clients' security policy won't allow the job to call an MS-DOS batch file which runs the DTSX package.
Or is there really some other way to stop the Log filename from re-evaluating on every write?


View 8 Replies


ADVERTISEMENT

Putting Date Or Date && Time In A Column Thats Going To Be Heavily Used?

Oct 4, 2007

Hello,

We have a bunch of Audit tables that contain almost exact copies of the operations tables. The audit tables also include:

AuditID - the audit action (insert, modify - old, modify - new, deleted)
AuditDate - date and time of action
AuditUser - User who did it...

At the end of the day I need to know for any given record what it looked like at the beginning of the day and what it looks like at the end of the day. There could have been numerous changes to the record throughout the day, those records I am not interested in. Only the first record and the last record of a give day.

I am going to be doing a lot of MIN(AuditDate) and MAX(AuditDATE) and .. WHERE AuditDate BETWEEN '10/1/2007 00:00:00' AND '10/1/2007 11:59:59' ...

Question: Whats better for performance:

1. Separating out the date and time and doing a clusterd index on the date.

2. Keeping date and time in the same column and just use a normal index.

3. Better ideas?

Thanks,
Bradley

View 1 Replies View Related

Putting Date Into SQL Server

Feb 2, 2006

I'm trying to put a date into a SQL Server table.  The database field type is "smalldatetime".  The variable dDate is type "date" and contains: 2/2/2006 (although I think Cdate actually converts it to: #2/2/2006#).  When I run the following code the date in the database is always ends up being: 1/1/1900.
Dim cmd As SqlCommand = New SqlCommand("INSERT INTO MyTable(MyDate) " & _                                 "VALUES (" & dDate & ")", SqlConn)daAppts.InsertCommand = cmddaAppts.InsertCommand.Connection = SqlConndaAppts.InsertCommand.ExecuteNonQuery()
Any other field types work fine, it's just dates that aren't working ????  Can someone please provide a code snippet showing me what I'm doing wrong??
 

View 3 Replies View Related

Question On Getting The Date Value Into A Filename

Dec 18, 2006

I am running the following sqllitespeed backup script on Windows 2003 Server
against SQL Server 2000



sqllitespeed -Bdatabase -T -DNorthwind -FH:MicrosoftSQLServerBACKUPSDATABACKUPSNorthWi ndorthwind.bak


How could I place the date variable into the output filename?

I've tried variations of %date% etc but nada.

Any thoughts?

Thanks in advance.

Gerry

View 3 Replies View Related

Retrieve Date From Filename

Apr 29, 2006

Hye all,

I need help on this.

Let say my source file in excel format. Currently i'm using foreach loop to execute those source files. The problem is that , i want to retrieve a date from the source(filename) itself. i've tried using derived column. but it doesnt work.

eg: Source file name Email_Jan_05.xls, i want to grab the string JAN and 05 which later i'm going to put it in my database.

any suggestion? Thanks in advance.

View 4 Replies View Related

Conversion Of Oracle Date Time To Sql Server Date Time In SSIS

Jun 30, 2007

This is driving me nuts..



I'm trying to extract some data from a table in oracle. The oracle table stores date and time seperately in 2 different columns. I need to merge these two columns and import to sql server database.



I'm struggling with this for a quite a while and I'm not able to get it working.



I tried the oracle query something like this,

SELECT
(TO_CHAR(ASOFDATE,'YYYYMMDD')||' '||TO_CHAR(ASOFTIME,'HH24:MM : SS')||':000') AS ASOFDATE

FROM TBLA

this gives me an output of 20070511 23:06:30:000



the space in MM : SS is intentional here, since without that space it appread as smiley



I'm trying to map this to datetime field in sql server 2005. It keeps failing with this error

The value could not be converted because of a potential loss of data



I'm struck with error for hours now. Any pointers would be helpful.



Thanks

View 3 Replies View Related

Adding Date To Filename In Report Subscription

Apr 26, 2007

My company sends reports on a daily basis to our customers. Now I want to save all the sent reports on disc with the date in the filename. I have set up a subscription which daily saves the files where I want them. However, I haven't found a way to add the date easily. I already have a parameter when creating the report, it is called Date. Does anybody know if I can use a parameter or something else?



Thank's

View 10 Replies View Related

Integration Services :: Expression To Parse Filename To A Date

Aug 7, 2015

I am very new to SSIS.  I need a package to iterate through files in folders and subfolders, evaluate the date of the file and delete them if they are over 90 days. I am using the following as a guide.  The reason I am not using a maintenance plan for this is that I did not see a way to use a built in maintenance plan task to copy files.  I already built a package that copies files to the destination.  Now I need to delete files in the destination that are over 90 days old.  

[URL] ...

I have a File System Task to delete files. I have a Script Task with a precedence constraint where I need to build an expression on the constraint between the Script Task and the File System Task for the delete.  

I have database backups in the format of SQLInstanceName_DatabaseName_BackupType_YYYYMMDD_XXXXXXX.bak.  

I created a variable to store the filename and I need an expression that will convert a file name like :

MySQLInstance_MyDB_DIFF_20150803_1700000.bak into 20150803, compare it to getdate -90 days.  

I created another variable for the Max File Age.  I built the below but when I click on Evaluate Expression I get an error stating, "The expression might contain an invalid token, an incomplete token, or an invalid element." 

DATEDIFF("dd",(DT_DATE)(SUBSTRING(RIGHT( @[User::strFileName], 20 ),1,8), GETDATE()) >  @[User::intFileMaxAge]

View 5 Replies View Related

SQL Server 2008 :: Loop Through Date Time Records To Find A Match From Multiple Other Date Time Records?

Aug 5, 2015

I'm looking for a way of taking a query which returns a set of date time fields (probable maximum of 20 rows) and looping through each value to see if it exists in a separate table.

E.g.

Query 1

Select ID, Person, ProposedEvent, DayField, TimeField
from MyOptions
where person = 'me'

Table

Select Person, ExistingEvent, DayField, TimeField
from MyTimetable
where person ='me'

Loop through Query 1 and if it finds ANY matching Dayfield AND Timefield in Query/Table 2, return the ProposedEvent (just as a message, the loop could stop there), if no match a message saying all is fine can proceed to process form blah blah.

I'm essentially wanting somebody to select a bunch of events in a form, query 1 then finds all the days and times those events happen and check that none of them exist in the MyTimetable table.

View 5 Replies View Related

Adding Current Date Into Attachment Filename In Reporting Service

May 30, 2006

Hi there,

I have been using reporting service to generate my report and sending email with attachment report via subscription everyday. It is work well and no error.

My attachment file name is as same as reportname project. But customers asked me to add current date into an attachment filename which will help them to identify the report. I try to check in rsreportserver.config to change it but have no idea.

My reportname project is daily_file.rdl and my attachment filename in email is daily_file.csv. I'd like to change my attachment filename as day_month_year_file.csv.

Is there anyone know how to change an attachment filename to be not the same as reportname in reporting service 2005

Regards,

View 3 Replies View Related

How To Concatenate Variables For RAW Output Filename I.e.@path + @filename?

Sep 7, 2007

Doesn't appear you can do this.

Am I wrong?

Please tell me I am.

View 11 Replies View Related

SSIS Execution Error: FlatFile Connection Problem - FileName &&<fileName&&> Specified In The Connection Was Not Valid.

Apr 19, 2008



Hi Champs,

Scenario Configuration : VB.net 2005 Code, WebService for Executing SSIS on Server, SSIS deployed on the Database Server

Problem Description : We are developing windows applicaiton in which we call webservice which was deployed on the same server where SSIS packages are deployed.
Now from Code we are passing FilePath name in variable and execute the Package. But the SSis result says that
The file name "\computernamefol1fol2fol3fol4abc.txt" specified in the connection was not valid.

More Information:

1. Full Permission are given on this network folder.
2. Package executes successfully from SSIS development solution (BIS solution)
3. Deployed packed executes successfully from the Database Server.
4. From Development pc packege executes successfully.
5. Other packages deployed on the same server executed suucessfully with same configuration and scenario.

Only this package is not executing.


-- the only differece with this package with other is -

using ".txt" extension in Flat file connection and using VB Script task


Can any one suggest the appropirate solution for this problem...

Thanks
Tarang Pandya

View 21 Replies View Related

Integration Services :: Exclude Time In Date Time Variable In SSIS For Loop?

Oct 22, 2015

I am trying to load previous days data at 3 am via a SSIS job.

The Date variable is initiated as DATEADD("dd",-1, GETDATE()) in the for loop.

Now, as this job runs at 3 am, and I set the variable as GETDATE() - 1, it excluded the data from 12 am to 3 am in the resultset as Date is set as YYYY-MM-DD 03:00:00:000 I need this to be set as YYYY-MM-DD 00:00:00:000

How can i do this? 

View 2 Replies View Related

How To Convert A Date (date/time) To A Julian Date

Jun 13, 2002

In SQL Server 2000:

How do I convert a Julian date to a Gregorian date?

How do I convert a Gregorian date to Julian?

Examples please.

Many thanks in advance.

Gary Andrews

View 2 Replies View Related

Date Function - Conversion Failed When Converting Date And / Or Time From Character String

Mar 18, 2014

I have the following

Column Name : [Converted Date]
Data Type : varchar(50)

When I try and do month around the [Converted Date] I get the following error message

“Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.”

My Query is

SELECT
month([Created Date])
FROM [FDMS_PartnerReporting].[Staging].[Salesforce_MarketingReporting]

View 7 Replies View Related

Transact SQL :: Due Date - Conversion Failed When Converting Date And / Or Time From Character String

Nov 16, 2015

SELECT * ,[Due]
  FROM [Events]
 Where Due >= getdate() +90

This returns the error: Conversion failed when converting date and/or time from character string

Why would this be? How to cast or convert this so that it will work? 

View 24 Replies View Related

How Do I Convert A Unix Date/Time Field To A Date When The The SQL DB Stores That Data As Char 11?

Nov 13, 2007

Hi there.
I'm trying to extract data from my SQL server & everything in the script I've got is working (extracting correct data) except for one field - which is for the most part it's off by +2 days (on a few occasions - I see it off by just +1 day or even +3, but it's usually the +2 days).

I'm told that it's due to the conversion formula - but - since SQL is not my native language, I'm at a bit of a loss.

The DB table has the date field stored as a type: CHAR (as opposed to 'DATE')
Can anyone out there help?

Please advise. Thanks.

Best.
K7

View 1 Replies View Related

Sharepoint Integration With Erroneous Date Format In Date Time Picker

Sep 5, 2007

Dear Expert!

A server with SQL 2005 sp2, Reporting Services and Sharepoint services (ver 3.0) (in integrated mode) gives an odd error. When viewing a Reporting Services report with a Date Time Picker, the date chosen is wrong. The preferred setting is Danish with the date format dd-mm-yyyy. The date picker shows the months in Danish but when selecting a date, and clicking on the Apply-button, the date reformats to US (mm-dd-yyyy).

Example:
When choosing 5th of September 2007 and clicking apply, it shows in the picker, 9th of May 2007.
When choosing 26th of September 2007 and clicking apply, it shows, again in US format, the RIGHT date but adds a timestamp 12:00 AM? in the end, making further enquiries to fail.

The report itself receives the right date and shows correctly. The only case it fails is, when the time stamp appears.

The server is a 32-bit one with 4 GB RAM. A testserver with identical collation on the Reportserver database cannot recreate the error. The site containing the reports has been set to Danish in the regional settings. To Reinstall is not an option.

The test report has no database connection whatsoever.

When setting the site to US, the timestamp wont appear at all.

The server has been restarted and the installation procedure was of the simple kind. No special tweaks at all.

Any advice would be greatly appreciated.

Kind Regards

Johan Rastenberger

View 1 Replies View Related

Use A DTS Package To Create An Excel, Which Has In The Filename The Date The Package Is Ran

Dec 19, 2006

I am trying to create a DTS Package which will run a SQL query and export the results to an Excel file.  I would like to the name of the excel to be "dynamic".  What I would like is for the name to be ChronicDownSiteReport - mmddyy.xls.  The mmddyy is the date which the package is executed.
 How can I do this? 
Also, I want this package to be excuted at 1am every Sunday Morning.  I have attempted to schedule this to run, but when I come to work on Monday, the excel file is not present and the email, which is sent telling me that the file was created is not in my mailbox. 

View 2 Replies View Related

How To Find Out Date/time When Row Was Updated Last Time

Jan 15, 2002

Hello,
we need to track date/time of last update for each record in a table.

As we understand it, we can't use field type Timestamp as this type does
not use dates/times.

Is there any SQL function available which we can bind to a column or
do we really have to use triggers?

Greetings from Mannheim, Germany
Ricardo

View 2 Replies View Related

How To Find Out Date/time When Row Was Updated Last Time

Jan 15, 2002

Hello,
we need to track date/time of last update for each record in a table.

As we understand it, we can't use field type Timestamp as this type does
not use dates/times.

Is there any SQL function available which we can bind to a column or
do we really have to use triggers?

Greetings from Mannheim, Germany
Ricardo

View 1 Replies View Related

Update Time In Date-time Field?

Nov 11, 2013

I want to update the time in a datetime field with the current time.

Fields current value is:

2013-11-11 00:00:00.000

I want to insert this into another table and when I do I want to grab the current time and update that field.

field name: picked_dt
Table: oeordlin

or is there a way through sql to update the time when the picked_dt is updated?

View 2 Replies View Related

Add Time To Datetime Value And Split Into Date And Time

Jun 12, 2007

Hi



i have the following situation. in my database i have a datetime field (dd/mm/yy hh:mms) and i also have a field timezone.

the timezone field has values in minutes that i should add to my datetime field so i have the actual time.

afterwards i split the datetime into date and time.

the last part i can accomplish (CONVERT (varchar, datetime, 103) as DATEVALUE and CONVERT (varchar, DATETIME, 108) as TIMEVALUE).



could anybody tell me how i can add the timezone value (in minutes) to my datetime value ?

i do all the calculations in my datasource (sql).



Thanks

V.

View 3 Replies View Related

Display Only The Date Part Of A Date And Time Field?

Mar 16, 2014

I want to display only the date part of a date field which contains both date & time information.

For example I have the value '2013-11-14 00:00:00.000' in my result set, and ideally I would like to show only '2013-11-14'.

I have looked up the datepart() command, however I can't work out how to return all parts of the date, rather than just the year, month, or day.

View 3 Replies View Related

How To Convert Date-field To Date With Time Zone

Jul 4, 2014

I have passed createdDate from UI to Stored procedure.createdDate field declared with DateTime.it is having value 2014-07-01.I need to fetch records from the database based upon the created field.but Create_TM in database having value Date with timestamp.so how would i change the createdfield in stored procedure.

ALTER PROCEDURE [dbo].[ByDateRange]

@Feed VARCHAR(50),

@CreatedDate DATETIME

select * from Date_table where Create_TM = @CreatedDate

View 1 Replies View Related

Problem With Current Date For Date & Time Field

Dec 29, 2005

I have a table named "shift" and I need to setup my query to return only data where the field "startime" = today. The problem I am running into is the starttime field it laid out like "2005-12-29 14:00:00" with different time values. I need to ruturn everything that has todays date regardless of the time value. I tried using GetDate() but that is returning data for other days as well or just data before or after the current time. Does anyone have any suggestions? This is driving me crazy! Thanks, Garrett

View 7 Replies View Related

Formatting Date SQL Date To Remove Time

May 2, 2008

Hi,I need a way of changing the following SQL statement so that the dates are without the hh:mm:ss tt:"Select DISTINCT([StartDate]) From [Events]"How can this be done?Thanks,Curt.

View 4 Replies View Related

How To Convert Date String To Date Time

Jan 8, 2013

I have a table in which a date value is stored as varchar.some of these values are stored ina dd/mm/yyyy format and other values are stored in a yyyy-mm-dd format..Now I wish to retrieve some data by querying between two dates. However I need to convert the varchar date value to datetime in order to do this but since the date value is in two different formats, the following doesn't work.

select date_value
from my_table
where CONVERT(DATETIME, date_value, 103) between @date1 and @date2

How can you convert the date value to datetime when its stored in mutiple formats. I can't change the table itself as I dont have admin privelages.

View 14 Replies View Related

Date Time Format For Date Parameter

Jan 24, 2008



Hello,

I am using the calender parameter and I need to convert my data date format to the one that matched that is returned on selecting a date from this calender. Can you show me what this format is.

how can I convert my existing date format to this format. The existing date format is 2007-07-26 21:27:13.000

thank you
Kiran

View 5 Replies View Related

Getting Time From Date/time Column

May 16, 2008

How can I obtain just the time portion from a date/time column?
My data contains "2008-05-19 09:30:00.000"
Actually, all I want/need is the hh:mm part of it.

Thanks,
Walt

View 2 Replies View Related

Date Part Of Date Time

May 5, 2004

SELECT ltrim(str(datepart(yyyy,getdate()))) +'-'+
replicate('0',2-len(ltrim(str(datepart(mm,getdate())))))+ltrim(str (datepart(mm,getdate())))+'-' +replicate('0',2-len(ltrim(str(datepart(dd,getdate())))))
+ltrim(str(datepart(dd,getdate())))

This is how i am getting datepart of datetime.Is there any other way to get the date and also time seperately..

Thanks.

View 14 Replies View Related

Group By Date But Not Date Time

Feb 28, 2008

i have a query
select mydate,lastname from users
group by mydate,lastname

now the only thing is mydate is a datetime fields but i want the results to group by just the date for each lastname entered.
How do i do this?

View 3 Replies View Related

Converting Date/time To Just Date?

Jul 20, 2005

I have a table that's of type date/time (i.e. 01/01/1900 00:00:00).What I want is to do the following:Say you have these records:person | date-time-------+---------------------------jim | 06/02/2004 00:05:52jim | 06/02/2004 05:06:21jim | 06/02/2004 05:46:21jim | 06/15/2004 11:26:21jim | 06/15/2004 11:35:21dave | 06/04/2004 09:35:21dave | 06/04/2004 11:05:21dave | 06/06/2004 10:34:21dave | 06/08/2004 11:37:21I'd like the results to count how many days and returnperson | days-------+-------jim | 2dave | 3How would I do this?--[ Sugapablo ][ http://www.sugapablo.com <--music ][ http://www.sugapablo.net <--personal ][ Join Bytes! <--jabber IM ]

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved