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 |
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2008-12-12 : 06:05:55
|
| Hi i want my rundate to display in 'yyyymmdd' format for which i usedCONVERT (CHAR (4),DATEPART(YY,GETDATE()))),101) + CONVERT(CHAR(10),CONVERT(DATETIME,LTRIM(RTRIM(VOUCHERMONTH)) +'01'date i want to be '01' always month will be taken from voucher monthnow my problem is that it is not getting that date in the format which i needi even used the format 101 and saw instaed of '112'susan |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-12 : 06:14:26
|
| [code]select left(convert(varchar,VOUCHERMONTH,112),6)+'01'[/code] |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-12 : 06:15:31
|
| SELECT Replace(CONVERT(VARCHAR(10), GETDATE(), 120),'-','') select CONVERT (CHAR(4),DATEPART(YY,GETDATE()))+ CONVERT(CHAR(2),datepart(mm,LTRIM(RTRIM(VOUCHERMONTH))))+'01' |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-12 : 09:04:45
|
why converting to character data? if you want to get first date of voucher month this is enoughDATEADD(mm,vouchermonth-1,DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)) |
 |
|
|
|
|
|
|
|