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.
Author |
Topic |
Keshaba
Yak Posting Veteran
52 Posts |
Posted - 2008-01-31 : 02:12:27
|
Hi I am using Sql server 2005 Express I want to know how shall I retrieve all transaction from a table which is before the current Date .Please show me the sql query.I have used the following query But it was not working properlySELECT dbo.Inventory.ItemCode, dbo.ItemMaster.Description, dbo.Inventory.ItemType, dbo.Inventory.BrandName, dbo.Inventory.Size, SUM(dbo.Inventory.qty) AS TotalqtyFROM dbo.Inventory LEFT OUTER JOIN dbo.ItemMaster ON dbo.Inventory.ItemCode = dbo.ItemMaster.ItemCodeWHERE (dbo.Inventory.Voucherdate > { fn NOW() })GROUP BY dbo.Inventory.ItemCode, dbo.Inventory.ItemType, dbo.Inventory.BrandName, dbo.Inventory.Size, dbo.ItemMaster.DescriptionKeshab |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2008-01-31 : 02:13:26
|
Getdate().Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
Keshaba
Yak Posting Veteran
52 Posts |
Posted - 2008-02-01 : 00:11:01
|
Hi I itz okay but I want only the date part not time.If I run the sql query like this...Select getDate() as mydateI get the following result....2008-02-01 10:38:10.857 .I want to retrive only the date partKeshab |
 |
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-02-01 : 00:19:10
|
Select Convert(varchar(20),getDate(),103) as mydate. Look Books online for various date formats like 103,101 etc. If you are using this in fron end, better will be to use front end application to format date returned from getdate(). |
 |
|
YogeshDesai
Posting Yak Master
136 Posts |
Posted - 2008-02-01 : 09:53:32
|
Hi You have to convert the date part. try thisselect Convert(Varchar(12), GetDate(), 112)for date format you can change the numbersStyle ID Style Type0 or 100 mon dd yyyy hh:miAM (or PM)101 mm/dd/yy102 yy.mm.dd103 dd/mm/yy104 dd.mm.yy105 dd-mm-yy106 dd mon yy107 Mon dd, yy108 hh:mm:ss9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM)110 mm-dd-yy111 yy/mm/dd112 yymmdd13 or 113 dd mon yyyy hh:mm:ss:mmm(24h)114 hh:mi:ss:mmm(24h)20 or 120 yyyy-mm-dd hh:mi:ss(24h)21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h)126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces)130 dd mon yyyy hh:mi:ss:mmmAM131 dd/mm/yy hh:mi:ss:mmmAMSQL IN Minds |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-02-01 : 10:47:12
|
quote: Originally posted by Keshaba Hi I itz okay but I want only the date part not time.If I run the sql query like this...Select getDate() as mydateI get the following result....2008-02-01 10:38:10.857 .I want to retrive only the date partKeshab
select Date = dateadd(dd,datediff(dd,0,'2008-02-01 10:38:10.857'),0)Date ------------------------------------------------------ 2008-02-01 00:00:00.000(1 row(s) affected) CODO ERGO SUM |
 |
|
|
|
|
|
|