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 2000 Forums
 SQL Server Development (2000)
 date without hyphens

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-08-04 : 10:45:56
When i use this function , i get the firstday of previousmonth
DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-0-datepart(day,0),getdate())),0) AS [First Day Prio Month]


but i get the date in this format 2008-07-01 but i want the date in
this format 20080701(without hyphens).how can i get that?

Thanks in advance

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-04 : 11:00:19
quote:
Originally posted by akpaga

When i use this function , i get the firstday of previousmonth
DATEADD(mm,DATEDIFF(mm,0,dateadd(mm,-0-datepart(day,0),getdate())),0) AS [First Day Prio Month]


but i get the date in this format 2008-07-01 but i want the date in
this format 20080701(without hyphens).how can i get that?

Thanks in advance


Where do you want to show converted dates?

Madhivanan

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

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-08-04 : 11:04:31
in a select statement
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-04 : 14:08:16
do it in your front end application if you can else use

SELECT REPLACE(CONVERT(varchar(11),datefield,121),'-','')
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-05 : 02:58:19
quote:
Originally posted by visakh16

do it in your front end application if you can else use

SELECT REPLACE(CONVERT(varchar(11),datefield,121),'-','')


SELECT CONVERT(varchar(8),getdate(),112)

Madhivanan

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

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-08-05 : 12:44:32
Thanks -- madhivanan and visakh16
Go to Top of Page
   

- Advertisement -