Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help with GETDATE()

Author  Topic 

erica686
Starting Member

13 Posts

Posted - 2010-01-14 : 18:43:04
I have the following query:

select amount
where tran_date >= getdate()

the problem that i have is that the transaction date is: 15/01/2010 12:00:00 AM, but the getdate formula will give me 15/01/2010 9:36:AM. So all transactions for the 15th will be excluded.. is there anyway around this?

Thanks,
E

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-14 : 18:49:28
SELECT Amount
FROM Table1
WHERE TranDate >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-15 : 00:00:39
also see

http://visakhm.blogspot.com/2010/01/some-quick-tips-for-date-formating.html
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-15 : 01:43:43
quote:
Originally posted by visakh16

also see

http://visakhm.blogspot.com/2010/01/some-quick-tips-for-date-formating.html


IMO, it is more of omitting the time part than formating it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -