Solved

Use GetDate function in SSIS in SQL Command?

Posted on 2015-01-30
5
377 Views
Last Modified: 2016-02-15
I have an ADO.NET Source in an SSIS package and want to run a SQL Command to bring back my records and I cant figure out how to write my Where clause where myfield = GetDate() and this does not work. Can someone let me know how I can return all the records where myfield = Today?

Please and Thank you
0
Comment
Question by:jknj72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 40580524
>Where clause where myfield = GetDate()
GETDATE() is the datetime down to the milisecond (ish), so if you want just today without the time component then use CAST(GETDATE() as date)
0
 
LVL 12

Assisted Solution

by:Habib Pourfard
Habib Pourfard earned 250 total points
ID: 40580545
or you could write:
(DATEDIFF(d, myfield , GETDATE()) = 0)

Open in new window

0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40580765
btw Since you're using SSIS, it is a common practice to have an Execute SQL Task with SQL of 'SELECT GETDATE() as dt', then assign dt to an SSIS variable.  Then you have that variable to use elsewhere in your SSIS package, with any platform, and in expressions where you have to do things like rename an output file to include the current date.
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 40582308
try to make format

Where clause where    convert(nvarchar(10),myfield ,20)  =    convert(nvarchar(10), GetDate()  ,20)
0
 

Author Closing Comment

by:jknj72
ID: 40583833
thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database Owner 3 21
T-SQL: Need Group By to use "fuzzy logic"?? 3 29
Set arraylist as datatable 2 13
Need multiple Group By's 8 31
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question