Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 1st, 2003, 02:56 AM
dirkuz dirkuz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 3 dirkuz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
get date of yesterday

i'm trying to get the date of yesterday via sql script
but it's not going verry succesfull.


getting the date of today is no problem ;
select getdate() but that also shows the current time
witch i don't need.
What i need is the date of yesterday without time.

When using datepart i can retrieve an year or an moth,
but when trying both : datepart (year,month, sqlcolumwithdate)
i get an error : "the datepart function equires 2 arguments"

So this is not working either,
can annyone give me a hint / direction how to do this ?

Thnx

Reply With Quote
  #2  
Old May 1st, 2003, 10:13 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
try
Code:
datepart("d", -1, getdate())
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old May 2nd, 2003, 03:53 AM
dirkuz dirkuz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 3 dirkuz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this is not allowed, 2 parameters

the correct statement is :

Example :
select fullname from employees
where datediff (dd, lastworkingdaycolum, getdate()) = 1

This will show everybody who's lastworkingday was yesterday.



this was needed for an scheduled vb application that
creates an e-mail every morning showing employees
that are inactive.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > get date of yesterday


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT