[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Use GetDate function in SSIS in SQL Command?

Posted on 2015-01-30
5
Medium Priority
?
497 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 66

Accepted Solution

by:
Jim Horn earned 1000 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 1000 total points
ID: 40580545
or you could write:
(DATEDIFF(d, myfield , GETDATE()) = 0)

Open in new window

0
 
LVL 66

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

656 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