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
 General SQL Server Forums
 New to SQL Server Programming
 Help needed with cast

Author  Topic 

jectson
Starting Member

2 Posts

Posted - 2010-07-15 : 12:31:42
Hi!

I need some help with the cast function.

I have a procedure who needs input in this datetime format: "yyyy-mm-dd 00:00:00.000". (the timestamp needs to be 00:00:00.000 every time, but the date has to change. I would like to do the input in this format: dd.mm.yy

Can anyone help? I've been trying to figure this out the last 6 hours....
This is the beginning of my procedure:

*******************************

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[Tallinnsamling] @date1 AS datetime
AS

begin
SET NOCOUNT ON;

SELECT [StoreNo],SUM([TotalTurnover]) AS Salg INTO vbdtmp..Eansalestemp FROM [EANSales]
WHERE[SoldDate] = cast(convert(varchar(8),@date1,1) as datetime)
GROUP BY STORENO
ORDER BY STORENO

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-07-15 : 12:36:40
Is this you are looking for :

select convert(varchar,getdate(),104)

select convert(varchar,convert(datetime,'14.02.10',4),120)

select convert(datetime,'14.02.10',4)
Go to Top of Page

jectson
Starting Member

2 Posts

Posted - 2010-07-15 : 13:31:48
quote:
Originally posted by pk_bohra

Is this you are looking for :

select convert(varchar,getdate(),104)

select convert(varchar,convert(datetime,'14.02.10',4),120)

select convert(datetime,'14.02.10',4)



I dont want the input date to be a DATETIME, because I want to be able to type witch date I want. Thats why I'm using the @date1
Go to Top of Page
   

- Advertisement -