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
Solved

Use GetDate function in SSIS in SQL Command?

Posted on 2015-01-30
5
359 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

839 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